classnames-generics
v1.0.9
Published
Use the classnames library more type-safely.
Downloads
3,565
Maintainers
Readme
classnames-generics
Use the classnames library more type-safely.
Install
npm i classnames-generics
Usage
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 });