# Badge

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

Small label for statuses, categories, and counts.

```python
from refast.components import Badge

Badge(children=["New"])
Badge(children=["Error"], variant="destructive")
Badge(children=["Active"], variant="success")
Badge(children=["Draft"], variant="outline")

# With icons
Badge(children=["Verified"], icon="check-circle")
Badge(children=["Warning"], icon="alert-triangle", variant="warning")
Badge(children=["New"], icon="arrow-right", icon_position="right")

# Sizes
Badge(children=["Tiny"], size="xs")
Badge(children=["Small"], size="sm")
Badge(children=["Default"], size="md")
Badge(children=["Large"], size="lg")
Badge(children=["XLarge"], size="xl")
```

Badge

## Props

| Prop | Type | Default | Description |
|------|------|---------|-------------|
| `children` | `list \| Component \| None` | `None` | Badge content (usually a short string) |
| `variant` | `"default" \| "secondary" \| "destructive" \| "outline" \| "success" \| "warning"` | `"default"` | Visual style |
| `icon` | `str \| None` | `None` | Lucide icon name (e.g. `"check"`, `"star"`, `"alert-circle"`) |
| `icon_position` | `"left" \| "right"` | `"left"` | Position of the icon relative to badge text |
| `size` | `"xs" \| "sm" \| "md" \| "lg" \| "xl"` | `"md"` | Size of the badge |
| `id` | `str \| None` | `None` | Unique element ID |
| `class_name` | `str` | `""` | Extra Tailwind classes |

## Variants

| Variant | Use case |
|---------|----------|
| `default` | Primary / highlighted label |
| `secondary` | Low-emphasis label |
| `destructive` | Error or danger state |
| `outline` | Subtle bordered label |
| `success` | Positive / active state |
| `warning` | Caution state |

## Sizes

| Size | Description |
|------|-------------|
| `xs` | Extra small — compact inline use |
| `sm` | Small |
| `md` | Default |
| `lg` | Large |
| `xl` | Extra large |

## Examples

```python
# Status indicators with icons
Row(
    gap=2,
    children=[
        Badge(children=["200 OK"], variant="success", icon="check"),
        Badge(children=["Deprecated"], variant="warning", icon="alert-triangle"),
        Badge(children=["Beta"]),
    ],
)

# Icon on the right
Badge(children=["Explore"], icon="arrow-right", icon_position="right")

# Size scale
Row(
    gap=2,
    class_name="items-center",
    children=[
        Badge(children=["xs"], size="xs"),
        Badge(children=["sm"], size="sm"),
        Badge(children=["md"], size="md"),
        Badge(children=["lg"], size="lg"),
        Badge(children=["xl"], size="xl"),
    ],
)

# With count
Badge(children=["12 new"], variant="secondary")
```

---

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