Whisq v0.1.0-alpha.9
rcx()
Compose class names reactively — returns a getter function for use with reactive class props.
Signature
Section titled “Signature”function rcx(...args: (string | (() => string | false | null | undefined) | false | null | undefined)[]): () => stringAny positional argument can be a plain string, a falsy value (false / null / undefined), or a getter function returning string-or-falsy. Falsy values and falsy getter returns are skipped; remaining classes are space-joined.
Examples
Section titled “Examples”One static class
Section titled “One static class”div({ class: rcx("btn") })Static base + reactive toggle
Section titled “Static base + reactive toggle”const loading = signal(false);
div({ class: rcx("btn", () => loading.value && "btn-loading"),})All reactive
Section titled “All reactive”const theme = signal<"light" | "dark">("light");const size = signal<"sm" | "md" | "lg">("md");
div({ class: rcx( () => `theme-${theme.value}`, () => `size-${size.value}`, ),})Mixing with sheet() classes
Section titled “Mixing with sheet() classes”const s = sheet({ item: { padding: "0.5rem" }, active: { background: "var(--color-accent-low)" },});
const selected = signal(false);
li({ class: rcx(s.item, () => selected.value && s.active),})Multiple toggles
Section titled “Multiple toggles”const variant = signal<"primary" | "secondary">("primary");const loading = signal(false);
div({ class: rcx( "btn", () => variant.value === "primary" && "btn-primary", () => variant.value === "secondary" && "btn-secondary", () => loading.value && "btn-loading", ),})Docs current to v0.1.0-alpha.9 . All releases →