[]previous and next page

ClassValue

A class value in the clsx style the runtime understands: strings, numbers (0 is dropped), booleans, nested arrays and objects whose truthy keys become class names.

A class value in the clsx style the runtime understands: strings, numbers (0 is dropped), booleans, nested arrays and objects whose truthy keys become class names. null, undefined and false remove the class attribute.

Import#

ts
import type { ClassValue } from "@shadow-js/web";

Signature#

ts
type ClassValue =
  | string
  | number
  | boolean
  | null
  | undefined
  | ClassArray
  | ClassDictionary

Examples#

ts
import type { ClassValue } from "@shadow-js/web";

const active = true;
const classes: ClassValue = ["card", { "card--active": active }, undefined];
const card = <div class={classes} />;