Skip to content
esc

Button

Actionshadcn/ui

Triggers an action. One default (black) button per view; everything else steps down to secondary, outline or ghost.

When to use

  • Use size lg with className 'w-full' for the single main action at the bottom of a mobile screen.
  • Pair default with ghost or outline for Cancel / Confirm.
  • Keep brand for at most one button per screen.
  • Don't put two default buttons side by side.
  • Don't disable a submit button to signal errors; show the error on the field.
  • Don't use destructive outside a confirmation step.

Accessibility

Role
button
Keyboard
Enter and Space activate. Tab moves focus; the focus ring uses color.border.focus.
Notes
Icon-only buttons (size icon) need aria-label.
Note
Loading sets aria-busy and disables the button so it is not submitted twice.
Note
Minimum touch target 44px: use default or lg on touch screens.

Props

  • variant= 'default'

    'default' | 'brand' | 'secondary' | 'outline' | 'ghost' | 'destructive' | 'link'

    Visual weight.

  • size= 'default'

    'default' | 'sm' | 'lg' | 'icon' | 'icon-sm' | 'icon-lg'

    Height and text size.

  • loading= false

    boolean

    Spinner, aria-busy and no clicks; stays at full opacity.

  • asChild= false

    boolean

    Render the child (e.g. a Link) with button styles, via Radix Slot. Pass a single child; loading has no spinner in this mode.

  • disabled= false

    boolean

    Native disabled; 40% opacity.

Prompt for your agent

Use the UnbuiltUI Button. Call unbuilt_get_component("Button") first and follow its spec: variants, states, usage rules and accessibility.

unbuilt_get_component returns

13 variants5 states5 props6 usage rules5 a11y notes17 tokens5 examples

Add it with shadcn

$npx shadcn add https://unbuiltui.com/r/button.json

Tokens · 17

bg.inversebg.inverse-hoverfg.inverseaccent.defaultaccent.hoverfg.on-accentbg.subtlebg.raisedbg.surfaceborder.subtleborder.defaultborder.focusdanger.defaultradius.smradius.mdmotion.fastmotion.ease