An open API service indexing awesome lists of open source software.

https://github.com/activeguild/classnames-generics

Use the classnames library more type-safely.
https://github.com/activeguild/classnames-generics

Last synced: 12 months ago
JSON representation

Use the classnames library more type-safely.

Awesome Lists containing this project

README

          

Welcome 😀


GitHub Actions status

# classnames-generics
Use the classnames library more type-safely.

## Install

```shell
npm i classnames-generics
```

## Usage

```ts

import {classNames } from 'classnames-generics';

classNames<'foo' | 'bar'>('foo', 'bar');
classNames<'foo' | 'bar'>('foo', { bar: true });
classNames<'foo-bar'>({ 'foo-bar': true });
classNames<'foo-bar'>({ 'foo-bar': false });
classNames<'foo' | 'bar'>({ foo: true }, { bar: true });
classNames<'foo' | 'bar'>({ foo: true, bar: true });
classNames<'foo' | 'bar'| 'duck' | 'baz' | 'quux'>('foo', { bar: true, duck: false }, 'baz', { quux: true });

import {classNamesFunc } from 'classnames-generics';

const classNames = classNamesFunc<'foo' | 'bar'>();

classNames('foo', 'bar');
classNames('foo', { bar: true });

```