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.
- Host: GitHub
- URL: https://github.com/activeguild/classnames-generics
- Owner: activeguild
- License: mit
- Created: 2021-10-09T14:13:51.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-03-14T13:08:45.000Z (about 3 years ago)
- Last Synced: 2025-04-05T00:35:01.637Z (about 1 year ago)
- Language: Shell
- Size: 40 KB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Welcome 😀
# 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 });
```