> ## Documentation Index
> Fetch the complete documentation index at: https://prefab.prefect.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Button

> Interactive button component with multiple variants and sizes.

Buttons trigger actions and communicate intent. The `variant` parameter signals what kind of action the button performs, while `size` controls its dimensions.

## Basic Usage

> [card]
>
> ```python Python icon="python" theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
> from prefab_ui.components import Button
>
> Button("Save Changes")
> ```
>
> ```json Protocol icon="brackets-curly" theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
> {
>   "view": {
>     "type": "Button",
>     "label": "Save Changes",
>     "variant": "default",
>     "size": "default",
>     "disabled": false
>   }
> }
> ```

The label can be passed as a positional argument or as a keyword (`label="Save Changes"`).

## Variants

Each variant communicates a different intent to the user:

> [card]
>
> ```python Python icon="python" theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
> from prefab_ui.components import (
>     Button,
>     Grid,
> )
>
> with Grid(columns=3, gap=8):
>     Button("Default", variant="default")
>     Button("Destructive", variant="destructive")
>     Button("Outline", variant="outline")
>     Button("Secondary", variant="secondary")
>     Button("Ghost", variant="ghost")
>     Button("Link", variant="link")
>     Button("Success", variant="success")
>     Button("Warning", variant="warning")
>     Button("Info", variant="info")
> ```
>
> ```json Protocol icon="brackets-curly" theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
> {
>   "view": {
>     "cssClass": "gap-8 grid-cols-3",
>     "type": "Grid",
>     "children": [
>       {
>         "type": "Button",
>         "label": "Default",
>         "variant": "default",
>         "size": "default",
>         "disabled": false
>       },
>       {
>         "type": "Button",
>         "label": "Destructive",
>         "variant": "destructive",
>         "size": "default",
>         "disabled": false
>       },
>       {
>         "type": "Button",
>         "label": "Outline",
>         "variant": "outline",
>         "size": "default",
>         "disabled": false
>       },
>       {
>         "type": "Button",
>         "label": "Secondary",
>         "variant": "secondary",
>         "size": "default",
>         "disabled": false
>       },
>       {
>         "type": "Button",
>         "label": "Ghost",
>         "variant": "ghost",
>         "size": "default",
>         "disabled": false
>       },
>       {
>         "type": "Button",
>         "label": "Link",
>         "variant": "link",
>         "size": "default",
>         "disabled": false
>       },
>       {
>         "type": "Button",
>         "label": "Success",
>         "variant": "success",
>         "size": "default",
>         "disabled": false
>       },
>       {
>         "type": "Button",
>         "label": "Warning",
>         "variant": "warning",
>         "size": "default",
>         "disabled": false
>       },
>       {
>         "type": "Button",
>         "label": "Info",
>         "variant": "info",
>         "size": "default",
>         "disabled": false
>       }
>     ]
>   }
> }
> ```

## Sizes

The `size` prop scales a button's padding and text from `xs` through `lg`. Reach for the smaller sizes (`xs`, `sm`) when buttons are packed into dense surfaces like toolbars, table rows, or inline controls, and the larger `lg` when you want a primary call to action to stand out as the focal point of a screen.

> [card]
>
> ```python Python icon="python" theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
> from prefab_ui.components import (
>     Button,
>     Row,
> )
>
> with Row(gap=3, css_class="items-center"):
>     Button("Tiny", size="xs")
>     Button("Small", size="sm")
>     Button("Default", size="default")
>     Button("Large", size="lg")
> ```
>
> ```json Protocol icon="brackets-curly" theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
> {
>   "view": {
>     "cssClass": "gap-3 items-center",
>     "type": "Row",
>     "children": [
>       {
>         "type": "Button",
>         "label": "Tiny",
>         "variant": "default",
>         "size": "xs",
>         "disabled": false
>       },
>       {
>         "type": "Button",
>         "label": "Small",
>         "variant": "default",
>         "size": "sm",
>         "disabled": false
>       },
>       {
>         "type": "Button",
>         "label": "Default",
>         "variant": "default",
>         "size": "default",
>         "disabled": false
>       },
>       {
>         "type": "Button",
>         "label": "Large",
>         "variant": "default",
>         "size": "lg",
>         "disabled": false
>       }
>     ]
>   }
> }
> ```

## With Icons

Buttons accept an `icon` prop (any [lucide icon name](https://lucide.dev/icons) in kebab-case). The icon renders before the label text.

> [card]
>
> ```python Python icon="python" theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
> from prefab_ui.components import Button, Row
>
> with Row(gap=3, css_class="items-center"):
>     Button("Download", icon="download")
>     Button("Settings", icon="settings", variant="outline")
>     Button("Delete", icon="trash-2", variant="destructive")
> ```
>
> ```json Protocol icon="brackets-curly" theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
> {
>   "view": {
>     "cssClass": "gap-3 items-center",
>     "type": "Row",
>     "children": [
>       {
>         "type": "Button",
>         "label": "Download",
>         "icon": "download",
>         "variant": "default",
>         "size": "default",
>         "disabled": false
>       },
>       {
>         "type": "Button",
>         "label": "Settings",
>         "icon": "settings",
>         "variant": "outline",
>         "size": "default",
>         "disabled": false
>       },
>       {
>         "type": "Button",
>         "label": "Delete",
>         "icon": "trash-2",
>         "variant": "destructive",
>         "size": "default",
>         "disabled": false
>       }
>     ]
>   }
> }
> ```

## Icon Sizes

Square buttons optimized for single icons. Use `icon` with an icon-size variant for icon-only buttons.

> [card]
>
> ```python Python icon="python" theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
> from prefab_ui.components import Button, Row
>
> with Row(gap=3, css_class="items-center"):
>     Button("", icon="plus", size="icon-xs")
>     Button("", icon="plus", size="icon-sm")
>     Button("", icon="plus", size="icon")
>     Button("", icon="plus", size="icon-lg")
> ```
>
> ```json Protocol icon="brackets-curly" theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
> {
>   "view": {
>     "cssClass": "gap-3 items-center",
>     "type": "Row",
>     "children": [
>       {
>         "type": "Button",
>         "label": "",
>         "icon": "plus",
>         "variant": "default",
>         "size": "icon-xs",
>         "disabled": false
>       },
>       {
>         "type": "Button",
>         "label": "",
>         "icon": "plus",
>         "variant": "default",
>         "size": "icon-sm",
>         "disabled": false
>       },
>       {
>         "type": "Button",
>         "label": "",
>         "icon": "plus",
>         "variant": "default",
>         "size": "icon",
>         "disabled": false
>       },
>       {
>         "type": "Button",
>         "label": "",
>         "icon": "plus",
>         "variant": "default",
>         "size": "icon-lg",
>         "disabled": false
>       }
>     ]
>   }
> }
> ```

## Button Type

Inside a `Form`, buttons default to `type="submit"`, which triggers form submission on click. Set `button_type="button"` for actions that should not submit the form, like cancel or close buttons.

```python theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
from prefab_ui.components import Button, Form
from prefab_ui.actions.mcp import CallTool

with Form(on_submit=CallTool("save")):
    # ... inputs ...
    Button("Cancel", variant="outline", button_type="button")
    Button("Save")  # defaults to submit
```

The three standard HTML button types are available: `"submit"` (default in forms), `"button"` (no form behavior), and `"reset"` (clears the form).

## Disabled State

Set `disabled=True` to signal that an action is unavailable right now and to block clicks until conditions change. The button dims and stops responding to interaction, which is the right state for a submit button while a form is incomplete or an operation that can't run until a prerequisite is met.

> [card]
>
> ```python Python icon="python" theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
> from prefab_ui.components import Button
>
> Button("Unavailable", disabled=True)
> ```
>
> ```json Protocol icon="brackets-curly" theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
> {
>   "view": {
>     "type": "Button",
>     "label": "Unavailable",
>     "variant": "default",
>     "size": "default",
>     "disabled": true
>   }
> }
> ```

## Custom Styling

Every component accepts `css_class` for additional Tailwind CSS classes. When your classes target the same CSS property as a built-in style (like `rounded-full` vs the default `rounded-md`), the built-in class is automatically removed so your override wins cleanly:

> [card]
>
> ```python Python icon="python" theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
> from prefab_ui.components import (
>     Button,
>     Column,
> )
>
> with Column(gap=3, css_class="items-start w-full"):
>     Button("Full Width Emerald", css_class="w-full bg-emerald-500")
>     Button("Pill Shape Rose", css_class="rounded-full bg-rose-500")
> ```
>
> ```json Protocol icon="brackets-curly" theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
> {
>   "view": {
>     "cssClass": "gap-3 items-start w-full",
>     "type": "Column",
>     "children": [
>       {
>         "cssClass": "w-full bg-emerald-500",
>         "type": "Button",
>         "label": "Full Width Emerald",
>         "variant": "default",
>         "size": "default",
>         "disabled": false
>       },
>       {
>         "cssClass": "rounded-full bg-rose-500",
>         "type": "Button",
>         "label": "Pill Shape Rose",
>         "variant": "default",
>         "size": "default",
>         "disabled": false
>       }
>     ]
>   }
> }
> ```

## API Reference

> [card] Button Parameters
>
> **label** `str` *required*
>
> Button text. Can be passed as a positional argument.
>
> **icon** `str | None` (default: None)
>
> Lucide icon name in kebab-case (e.g., `"arrow-right"`, `"trash-2"`). Browse icons at [lucide.dev/icons](https://lucide.dev/icons).
>
> **variant** `str` (default: default)
>
> Visual style: `"default"`, `"destructive"`, `"outline"`, `"secondary"`, `"ghost"`, `"link"`, `"success"`, `"warning"`, `"info"`.
>
> **size** `str` (default: default)
>
> Button dimensions: `"default"`, `"xs"`, `"sm"`, `"lg"`, `"icon"`, `"icon-xs"`, `"icon-sm"`, `"icon-lg"`.
>
> **button\_type** `str | None` (default: None)
>
> HTML button type: `"submit"` (default in forms), `"button"` (no form submit), or `"reset"`. Use `"button"` for cancel/close actions inside a Form.
>
> **disabled** `bool | str` (default: False)
>
> Whether the button is non-interactive. Accepts a template expression like `"{{ not $item.name }}"` for conditional disabling.
>
> **on\_click** `Action | list[Action] | None` (default: None)
>
> Action(s) to run when the button is clicked. Pass a list to sequence them; server actions like `CallTool` take their own `on_success`/`on_error` callbacks for follow-ups.
>
> **css\_class** `str | None` (default: None)
>
> Additional Tailwind CSS classes appended to the component's built-in styles.

## Protocol Reference

```json Button theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
{
  "type": "Button",
  "id?": "string",
  "onMount?": "any",
  "label": "string (required)",
  "icon?": "string",
  "variant?": "default | destructive | outline | secondary | ghost | link | success | warning | info | string",
  "size?": "default | xs | sm | lg | icon | icon-xs | icon-sm | icon-lg",
  "buttonType?": "submit | button | reset",
  "disabled?": "boolean | string",
  "onClick?": "Action | Action[]",
  "cssClass?": "string"
}
```

For the complete protocol schema, see [Button](https://prefab.prefect.io/docs/protocol/button.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.