# Button

- **Section:** Components
- **URL:** https://refast.fastapicloud.dev/docs/components/button
- **Markdown:** https://refast.fastapicloud.dev/docs/components/button.md
- **Source:** https://github.com/idling-mind/refast-docs/blob/main/docs/pages/components/buttons/button.py
- **Live examples:** the widgets on this page need a browser; open the URL above to try them.
- **Applies to:** refast 0.12.2

A standard clickable button styled with shadcn/ui conventions.

```python
from refast.components import Button

Button("Save", on_click=ctx.callback(handle_save))
Button("Delete", variant="destructive", icon="trash", on_click=ctx.callback(handle_delete))
Button("Next", variant="ghost", icon="arrow-right", icon_position="right")
Button("Processing…", loading=True)
```

```python
Button(
    "Click me",
    variant="default",
    size="md",
    disabled=False,
    loading=False,
    on_click=ctx.callback(handle_click),
)
```

## Props

| Prop | Type | Default | Description |
|------|------|---------|-------------|
| `label` | `str` | *(positional)* | The button text. |
| `variant` | `"default" \| "secondary" \| "destructive" \| "outline" \| "ghost" \| "link"` | `"default"` | Visual style. ``"default"`` is the primary filled style. |
| `size` | `"xs" \| "sm" \| "md" \| "lg" \| "xl"` | `"md"` | Button size. ``"icon"`` renders a square icon-only button. |
| `icon` | `str \| None` | `None` | Optional Lucide icon name (e.g. ``"save"``, ``"trash"``). |
| `icon_position` | `"left" \| "right"` | `"left"` | Whether the icon appears before or after the label. |
| `disabled` | `bool` | `False` | Prevents interaction when ``True``. |
| `loading` | `bool` | `False` | Shows a spinner and sets ``disabled`` when ``True``. |
| `type` | `"button" \| "submit" \| "reset"` | `"button"` | HTML ``<button>`` type attribute. |
| `on_click` | `Callback \| None` | `None` | Server callback invoked on click. |

`id`, `class_name` and `style` are accepted by every component and are documented on [Component Base](https://refast.fastapicloud.dev/docs/components/base).

## All Variants

```python
Button("Default")
Button("Secondary", variant="secondary")
Button("Destructive", variant="destructive")
Button("Outline", variant="outline")
Button("Ghost", variant="ghost")
Button("Link", variant="link")
```

## All Sizes

```python
Button("Extra Small", size="xs")
Button("Small",       size="sm")
Button("Medium",      size="md")
Button("Large",       size="lg")
Button("Extra Large", size="xl")
```

## With Icons

```python
Button("Save", icon="save")                                    # icon on left (default)
Button("Next", icon="arrow-right", icon_position="right")     # icon on right
```

## States

```python
Button("Disabled", disabled=True)
Button("Loading…", loading=True)
```

---

Part of the Refast documentation: [all pages](https://refast.fastapicloud.dev/llms.txt), [everything on one page](https://refast.fastapicloud.dev/llms-full.txt), [search](https://refast.fastapicloud.dev/api/search?q=save_prop).
