---
title: "Button"
description: "A button for an action on the page, such as Save or Delete. It has 9 looks and 5 sizes, and a spinner that keeps its width while the action runs."
url: https://gelatinui.com/components/button
markdown_url: https://gelatinui.com/components/button.md
access: free
install: "npx shadcn@latest add @gelatin-ui/button"
registry_item: https://gelatinui.com/r/button.json
version: "2026-11-08"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# Button

> A button for an action on the page, such as Save or Delete. It has 9 looks and 5 sizes, and a spinner that keeps its width while the action runs.

Page: https://gelatinui.com/components/button

## When to use it

Best for: An action on the page, such as Save, Send, or Delete, with a busy state that keeps its width.

- Use it for an action on the page: submit, save, open, delete.
- Set `busy` while the action runs. With the default `spinnerPlacement`, the button keeps its width and focus.
- Use an icon size (`icon`, `icon-sm`) for an action with only an icon, and give it an `aria-label`.

## When not to use it

- To go to another page, use a link, not a button. Put `buttonVariants` on the link to give it the look of a button.
- For a value that stays on or off, use a [Switch](https://gelatinui.com/components/switch.md).

## Notes for agents

- Button renders a native `<button>`. For a link with the button look, put `buttonVariants` on the link.
- Set `busy` while an async action runs: the button keeps its width and focus and blocks more clicks.
- An icon size (`icon-xs`, `icon-sm`, `icon`, `icon-lg`) has no text, so give it an `aria-label`.

## Anatomy

```text
Button
```

## API reference

### Button

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `glass` | `"clear" \| "dark" \| "light"` |  |  |
| `rounded` | `"default" \| "full"` |  |  |
| `size` | `"default" \| "icon" \| "icon-lg" \| "icon-sm" \| "icon-xs" \| "lg" \| "sm" \| "xl" \| "xs"` |  |  |
| `variant` | `"dashed" \| "default" \| "destructive" \| "destructive-outline" \| "ghost" \| "link" \| "media" \| "outline" \| "secondary"` |  |  |
| `className` | `string` |  |  |
| `busy` | `boolean` | false | The button waits for the app (busy words): a spinner, `aria-busy`, and no clicks. Focus stays on the button. The style hook stays `data-loading`. |
| `spinnerPlacement` | `"center" \| "start"` | "center" | `center` (default): the spinner covers the label. `start`: it takes the leading icon slot. The icon sizes always use `center`, because their one icon is the label. |

Also takes every prop of Base UI `Button`: https://base-ui.com/react/components/button

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| Button | `button` | `data-popup-open` |  | `status-colors` |

## Usage

Button renders a native `<button>`. Set `busy` while the action runs: the button keeps its width and its focus, and it blocks more clicks.

```tsx title="save-changes-button.tsx"
import { useState } from "react";

import { Button } from "@/components/ui/button";

export function SaveChangesButton({ onSave }: { onSave: () => Promise<void> }) {
  const [saving, setSaving] = useState(false);
  async function save() {
    setSaving(true);
    try {
      await onSave();
    } finally {
      setSaving(false);
    }
  }
  return (
    <Button size="lg" busy={saving} onClick={save}>
      Save changes
    </Button>
  );
}
```

## Compose

Build it with:

- [Sidebar](https://gelatinui.com/components/sidebar.md): Moves between the settings sections.
- [Frame](https://gelatinui.com/components/frame.md): Groups the fields of one section, with Save in its footer.
- [Field](https://gelatinui.com/components/field.md): Names each control and shows its help or error text.
- [Switch](https://gelatinui.com/components/switch.md): Turns one setting on or off at once.
- [Select](https://gelatinui.com/components/select.md): Picks one value from a short list.
- [Toast](https://gelatinui.com/components/toast.md): Confirms the save.
- [Form](https://gelatinui.com/components/form.md): Owns the submit and the errors.
- [Input](https://gelatinui.com/components/input.md): Takes short text.

Rules:

- Group with a Frame (`group-in-frames`): Put related panels in one `Frame` with its header and footer outside the panels, and keep a plain `Card` for one block of content.
- Name every control (`label-every-control`): Give every field a visible `Label` (or a `Field`), and every icon button a `Tooltip` or an `aria-label`.
- Labels real apps use (`real-labels`): Write the button and menu labels that real apps use ("Create API key", "Invite members"), with no "…" at the end.
- No layout jump (`no-layout-jump`): When a state change adds, removes, or resizes content, reserve its space or animate its size, so nothing below it jumps.

Patterns: `gelatin://patterns/settings-page`, `gelatin://patterns/form-flow`, `gelatin://patterns/confirm-action`

## Add it

```bash
npx shadcn@latest add @gelatin-ui/button
```

It adds 8 registry items: 5 files, 1351 lines, and the npm packages `@base-ui/react`, `tailwind-merge`, `tailwind-variants`.

## Built on

- [Spinner](https://gelatinui.com/components/spinner.md)

## For AI agents

- Every item, one file: https://gelatinui.com/llms.txt
- MCP server (`search_items`, `get_item`, `get_install_plan`): https://gelatinui.com/mcp

## Related

- [Copy Button](https://gelatinui.com/components/copy-button.md)
- [Spinner](https://gelatinui.com/components/spinner.md)
- [Alert Dialog](https://gelatinui.com/components/alert-dialog.md)

## Keyboard

| Keys | Action |
| --- | --- |
| Enter | Presses the button. |
| Space | Presses the button. |

## Accessibility

Button is a Base UI `Button`, a native `<button>`. Its text is its name. An icon size (`icon-xs`, `icon-sm`, `icon`, `icon-lg`) has no text, so give it an `aria-label`.

With `busy`, the button sets `aria-busy` and blocks clicks, but it stays in the tab order and keeps focus. The label stays in the accessibility tree under the spinner, and the spinner is hidden from screen readers (`aria-hidden`).

The 3px focus ring shows on keyboard focus only (`focus-visible`). An invalid button (`aria-invalid`) shows a red ring.

On a coarse pointer, `hit-area` grows the touch target to at least 44 × 44px. The button keeps its size on the screen.

## Motion

| Part | Motion |
| --- | --- |
| Press | press · 100ms · ease-out (0, 0, 0.2, 1) · moves down 1px |
| Loading | animate-spin · 1s · linear · repeats |
