Button
Button
Section titled “Button”useButton(options) creates a styled <button>; buttonClass(options) returns
the class list for SSR or framework templates.
Variants
Section titled “Variants”import { useButton } from "@katanakit/ui";
row.append( useButton({ label: "Primary" }), useButton({ label: "Secondary", variant: "secondary" }), useButton({ label: "Ghost", variant: "ghost" }), useButton({ label: "Danger", variant: "danger" }),);Sizes and states
Section titled “Sizes and states”useButton({ label: "Small", size: "sm" });useButton({ label: "Large", size: "lg" });useButton({ label: "Loading", loading: true });useButton({ label: "Disabled", disabled: true });Options
Section titled “Options”| Option | Type | Default | Notes |
|---|---|---|---|
label |
string |
"" |
Visible text. |
variant |
"primary" | "secondary" | "ghost" | "danger" |
"primary" |
Visual style. |
size |
"sm" | "md" | "lg" |
"md" |
Padding and font size. |
type |
"button" | "submit" | "reset" |
"button" |
Native type. |
loading |
boolean |
false |
Spinner, aria-busy and disabled interaction. |
disabled |
boolean |
false |
Native disabled state. |
onClick |
(event: MouseEvent) => void |
— | Attached with addEventListener. |
::: info SSR
The factories need a DOM. On the server use buttonClass() and render the
markup yourself — the classes are stable strings.
:::