Button
npx shadcn add @klarhimmel/buttonCopy for AIExamples
Variants
Sizes
States
With icon
As child
DetailsAbout, usage, props and more
Triggers an action. Five variants, three sizes, a 44 pixel hit area at every size.
When to use
Use for
Saving, sending, confirming a step. One primary button per view.
Not for
Going to another page. Use Button link or Text link.
Pairs with
Field, Card, Copy button.
Preview
Import
Import
- Files
- button.tsx, in components/klarhimmel/ui/. With it: editing, theme, utils. npm: radix-ui.
- Render in
- Render it inside <Theme>, once near the root of your app. Tokens and fonts are scoped to it, so outside it the component is unstyled.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
variant | 'primary' | 'secondary' | 'ghost' | 'accent' | 'soft' | 'danger' | 'primary' | Visual style. Primary is ink on canvas; danger is a quiet outline for ending or removing something. |
size | 'sm' | 'md' | 'lg' | 'md' | Height and padding. The hit area stays 44 px. |
icon | ReactNode | - | Icon before the label. |
iconEnd | ReactNode | - | Icon after the label. |
full | boolean | - | Stretch to the container width. |
asChild | boolean | - | Render the single child (an <a>, a router Link) with button styling instead of a <button>. |
native attributes | ButtonHTMLAttributes | - | Every native attribute of the element passes through, className included. |
Accessibility
| Key | Does |
|---|---|
Enter / Space | Activates the button |
Tab | Moves focus; the ring is always visible |
An icon-only button needs an aria-label.
Accessibility