web

Composes class name from truthy values with the support of string and objects.

Type signature

(...xs: unknown[]) => string

Examples

classNames("test", {
  active: true,
  disabled: false,
  on: undefined,
});
// ⇒ "test active"
Try in REPL

Questions

  • How to create a class name from an array of strings and/or objects?

TypeScript sourceJavaScript source