classes

Published 14 days ago - 1 min read

Implementation

Add multiple classes that can also be type boolean, null and undefined.

src/util/classes.ts
export function classes(...arr: (string | boolean | null | undefined)[]): string {
  return arr.join(" ");
}

Usage

<div className={classes("myClass", isTrue && "anotherClass")}>Hello world!</div>