classnames()
The classnames() method returns the class names conditionally joining.
Usage
import { classnames } from '@ponsetya/core'
Syntax
classnames(...args: ClassNameArgument[]): string
Parameters
- ...args:
ClassNameArgument[]
- Class name references.
- Returns:
string
- A String representing the name of the generated class.
Examples
classnames('foo', 'bar') // 'foo bar'
classnames({ foo: true, bar: false }) // 'foo'
classnames({ foo: true, bar: true }) // 'foo bar'
classnames({ foo: 'baz' }, { bar: true }) // 'foo-baz bar'
Type Aliases
Class Name Value
type ClassNameValue = string | number | boolean | undefined | null
Class Name Value Object
type ClassNameValueObject = Record<string, ClassNameValue>
Class Name Argument
type ClassNameArgument = ClassNameValue | ClassNameValueObject