# Icon Button

- **Section:** Components
- **URL:** https://refast.fastapicloud.dev/docs/components/icon-button
- **Markdown:** https://refast.fastapicloud.dev/docs/components/icon-button.md
- **Source:** https://github.com/idling-mind/refast-docs/blob/main/docs/pages/components/buttons/icon_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 square icon-only button. Useful for toolbars, action columns, and compact UIs where
a text label would take too much space.

```python
from refast.components.shadcn.button import IconButton

IconButton(icon="trash", aria_label="Delete item", on_click=ctx.callback(handle_delete))
IconButton(icon="settings", variant="outline", size="lg")
IconButton(icon="copy", variant="ghost")
```

```python
IconButton(
    icon="settings",
    variant="ghost",
    size="md",
    disabled=False,
    aria_label="settings",
    on_click=ctx.callback(handle_click),
)
```

## Props

| Prop | Type | Default | Description |
|------|------|---------|-------------|
| `icon` | `str` | *(required)* | Lucide icon name (e.g. `"trash"`, `"edit"`, `"settings"`) |
| `variant` | `"ghost" \| "default" \| "secondary" \| "destructive" \| "outline"` | `"ghost"` | Visual style |
| `size` | `"xs" \| "sm" \| "md" \| "lg" \| "xl"` | `"md"` | Button dimensions (also controls icon size) |
| `disabled` | `bool` | `False` | Prevents interaction |
| `aria_label` | `str \| None` | `None` | Accessible label — defaults to icon name if omitted |
| `on_click` | `Callback \| None` | `None` | Server callback invoked on click |
| `class_name` | `str` | `""` | Extra Tailwind classes |

## All Variants

```python
IconButton(icon="settings")                          # ghost (default)
IconButton(icon="settings", variant="default")
IconButton(icon="settings", variant="secondary")
IconButton(icon="settings", variant="destructive")
IconButton(icon="settings", variant="outline")
```

## All Sizes

```python
IconButton(icon="settings", size="xs")
IconButton(icon="settings", size="sm")
IconButton(icon="settings", size="md")
IconButton(icon="settings", size="lg")
IconButton(icon="settings", size="xl")
```

## With Accessible Label

```python
# Always provide aria_label for screen-reader accessibility
IconButton(icon="trash", aria_label="Delete item", on_click=ctx.callback(handle_delete))
```

## Common Use Cases

```python
# Toolbar actions
Row(children=[
    IconButton(icon="bold", aria_label="Bold"),
    IconButton(icon="italic", aria_label="Italic"),
    IconButton(icon="underline", aria_label="Underline"),
])

# Table row actions
Row(children=[
    IconButton(icon="edit", aria_label="Edit", on_click=ctx.callback(handle_edit)),
    IconButton(icon="trash", variant="destructive", aria_label="Delete",
               on_click=ctx.callback(handle_delete)),
])
```

---

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).
