Button
Starts the action the user came to do: save, create, confirm.
When to use
- Trigger an action on this page: save, create, confirm, delete.
- Submit a form.
When not to use
- Go to another page: use a link, or
buttonVariants()on aLink. - Turn a setting on or off: use Switch or Toggle.
- Pick one of several views: use Tabs or Toggle Group.
Install
npx shadcn@latest add @clinia/buttonMarketing (Sera)
Anatomy
- 1Container
data-slot="button"bg-primary · rounded-lg - 2Icon (optional)
[data-icon]size-4 · currentColor - 3Label
[data-part=label]text-sm · font-medium
Clinia rules
defaultis the one main action in a view: an Infinite fill, inverted in dark. It is never a Trust fill, because Trust can't carry label-size text.- Labels are sentence case and start with a verb that names the result:
Create source, notOK. - Keep the Trust focus ring. Don't override it with a custom outline.
destructiveis a tinted fill with destructive text, not a solid red button.
Do and don't
States: product (Luma)
Focus cells apply the component's focus-visible classes statically. Toggle the site theme to review both themes.
States: marketing (Sera)
Focus cells apply the component's focus-visible classes statically. Toggle the site theme to review both themes.
Sizes
| Size | Height | Padding x | Gap | Radius | Type |
|---|---|---|---|---|---|
| default | h-9 · 36px | px-3 · 12px | gap-1.5 · 6px | --radius-lg | text-sm · 14px |
| xs | h-6 · 24px | px-2.5 · 10px | gap-1 · 4px | --radius-lg | text-xs · 12px |
| sm | h-8 · 32px | px-3 · 12px | gap-1 · 4px | --radius-lg | text-sm · 14px |
| lg | h-10 · 40px | px-4 · 16px | gap-1.5 · 6px | --radius-lg | text-sm · 14px |
| icon | size-9 · 36px | – | – | --radius-lg | text-sm · 14px |
| icon-xs | size-6 · 24px | – | – | --radius-lg | text-sm · 14px |
| icon-sm | size-8 · 32px | – | – | --radius-lg | text-sm · 14px |
| icon-lg | size-10 · 40px | – | – | --radius-lg | text-sm · 14px |
Accessibility
Built in
- Focus-visible shows a solid Trust ring (
border-ring ring-3 ring-ring/30);aria-invalidswaps it to a destructive ring.
Your responsibility
- Give icon-only sizes (
icon,icon-sm…) anaria-label: the icon is decorative and names nothing. - Navigation is a link, not a button with an
onClick. PutbuttonVariants()on theLinkto keep the look. - Disable a button only when the reason is visible nearby. Otherwise keep it enabled and explain the problem when it's pressed.
- While it's loading, set
disabledand change the label to say what's happening (Saving). A screen reader doesn't read the change by itself, so announce the result in a toast or a status message.
How to test
- Press Tab until the button has focus: the Trust ring appears.
- Press Enter, then Space: each one activates it.
- With a screen reader, it's announced as its label, then as a button. Icon-only buttons announce their
aria-label.
API
| Prop | Values | Default | Description |
|---|---|---|---|
| variant | defaultoutlinesecondaryghostdestructivelink | default | Emphasis. |
| size | defaultxssmlgiconicon-xsicon-smicon-lg | default | Height: |
All other props come from Base UI Button.