Button
Triggers an action, such as saving, submitting a form, opening a dialog or running a destructive operation.
<Button size="sm" variant="primary">Salvar alterações</Button>When to use
- To run an action on the current screen: save, send, approve, delete.
- To open a dialog, drawer or menu that continues the same task.
- To submit a form.
When not to use
- Navigation to another page. Use a link. If it must look like a button,
use
asChildwith the app’sCustomLinkso it stays a real link. - Toggling a setting on or off. Use Switch or Checkbox.
- Choosing one option among several. Use Radio group or Tabs.
Variants
Variants set the visual hierarchy of the action. When no variant is passed, the
button is inverted.
| Variant | Use for |
|---|---|
primary |
The most important action in an area. One per screen. |
secondary |
A supporting action next to a primary. |
tertiary |
A low-emphasis action with a light surface fill and stroke. |
inverted |
Default. High contrast: dark fill on light themes. |
ghost |
The lowest emphasis: no fill until hover. Toolbars and dense tables. |
critical |
Destructive or irreversible actions: delete, remove, revoke. |
success |
Confirming a positive completion. |
warning |
Actions that need caution before running. |
link |
An inline text action with an animated underline. |
filter |
Filter triggers. data-active="true" marks an applied filter. |
fav |
A bookmark toggle. Icon only, with size="fav". |
Sizes
sm is the default and fits most screens. Icon-only buttons use the *Icon
sizes, which are square.
| Size | Height | Use for |
|---|---|---|
lg, lgIcon |
56px | Empty states and onboarding calls to action. |
md, mdIcon |
48px | Prominent actions, touch screens. |
sm, smIcon |
40px | Default. Forms, dialogs, page headers. |
xs, xsIcon |
36px | Compact layouts and toolbars. |
xxs, xxsIcon |
32px | Tables and dense lists. |
quiet |
24px | Minimal inline controls. |
fav |
32px | Only with variant="fav". |
States
- Hover and pressed come from
bg-color-mix, which blends the fill with the interactive color. - Disabled blocks pointer events and uses the disabled tokens.
- Loading (
isLoading) disables the button and adds a spinner. WithoutloadingTextthe label stays; with it, the label describes the action in progress.
Icons
Use 16px Lucide icons (className="size-4"). Put the icon before the label for
create and add actions, after it for actions that move forward or export.
Icon-only buttons have no visible text, so they always need an aria-label.
Navigation
With asChild, the button styles go to the child element. Use it when the
action navigates: the element stays a real link.
Content
- Start with a verb that names the result: “Salvar alterações”, “Gerar contestação”, “Enviar para revisão”.
- Use sentence case, 1 to 3 words, no final period.
- Name the object in destructive actions: “Excluir tarefa”, not “Excluir”.
- Avoid generic labels such as “OK”, “Sim” or “Clique aqui”.
- Write
loadingTextas the action in progress: “Salvando…”.
Do and don’t
Accessibility
- It renders a native
<button>, so Enter and Space activate it. - Inside a form, a button without
typesubmits the form. Settype="button"on actions that should not submit. - Icon-only buttons need an
aria-labelthat names the action. - Disabled buttons cannot receive focus. When an action is unavailable, explain why next to it instead of relying on the disabled state alone.
- Hit targets: every size is at least 24px tall. On touch screens use
mdor larger (44px minimum). - Keyboard focus has no custom style yet. See Known issues.
Code
import { Button } from "@repo/ui/button";
<Button variant="primary">Salvar alterações</Button>
// Navigation: keep a real link
<Button asChild variant="secondary">
<CustomLink href="/tarefas">Ver tarefas</CustomLink>
</Button>
// Icon-only
<Button aria-label="Fechar" size="smIcon" variant="ghost">
<X className="size-4" />
</Button>
// Loading
<Button isLoading loadingText="Salvando…" variant="primary">
Salvar
</Button>
Props
| Prop | Type | Default | Description |
|---|---|---|---|
asChild | boolean | false | Renders the child element (for example a link) with button styles, using Radix Slot |
disabled | boolean | false | Disables the button interaction |
isLoading | boolean | false | Shows a spinner and disables the button while keeping the label |
loadingText | string | — | Replaces the label while `isLoading` is true |
onClick | function | — | Click handler |
size | "fav" | "lg" | "lgIcon" | "md" | "mdIcon" | "quiet" | "sm" | "smIcon" | "xs" | "xsIcon" | "xxs" | "xxsIcon" | sm | Height, padding and type size |
variant | "critical" | "fav" | "filter" | "ghost" | "inverted" | "link" | "primary" | "secondary" | "success" | "tertiary" | "warning" | inverted | Visual hierarchy of the action |
Known issues
These are visible in the previews above because this site renders the real component. Fixing them changes the product, so each needs design sign-off.
| Issue | Effect |
|---|---|
The base classes have no focus-visible style. |
Keyboard focus shows only the browser’s default outline, not the --stroke-focus token. The old tech-docs page showed a custom focus ring that came from its preview CSS, not from the component. |
inverted, the default variant, has no hover or pressed fill. |
No visual feedback on hover or press. See the States grid. |
warning uses focus:ring-old-warning. |
Depends on a deprecated -old token. |
inverted, critical and success use disabled:opacity-25. |
Disabled uses transparency, unlike the other variants, which use the disabled tokens. |
ButtonProps is an interface and the component uses forwardRef. |
Code only: the repository prefers type, and React 19 accepts ref as a prop. |