Skip to content
Klarhimmel UI

Button

npx shadcn add @klarhimmel/button

Examples

  • 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

button.tsx
import { Theme } from '@/components/klarhimmel/theme/style';
import { Button } from '@/components/klarhimmel/ui/button';

export default function Example() {
  return (
    <Theme theme="brand">
      <div className="flex gap-3">
        <Button>Save changes</Button>
        <Button variant="secondary">Cancel</Button>
      </div>
    </Theme>
  );
}

Import

Import

import { Button } from '@/components/klarhimmel/ui/button';
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

PropTypeDefaultDescription
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.
iconReactNode-Icon before the label.
iconEndReactNode-Icon after the label.
fullboolean-Stretch to the container width.
asChildboolean-Render the single child (an <a>, a router Link) with button styling instead of a <button>.
native attributesButtonHTMLAttributes-Every native attribute of the element passes through, className included.

Accessibility

KeyDoes
Enter / SpaceActivates the button
TabMoves focus; the ring is always visible

An icon-only button needs an aria-label.

Accessibility