Files
2026-10-17 21:16:53 +08:00

44 lines
1.1 KiB
Plaintext

# Badge
A lightweight text widget for displaying short labels, statuses, and counts.
<WidgetExample name="badge-basic" />
## Use cases
- **Suitable**: marking a status or category in lists, cards, and forms
- **Suitable**: showing a brief count or hint label
- **Not suitable**: command controls that need to be clicked (use `button` instead)
## Usage
```tsx
import { Badge } from "@lcui/react"
```
```tsx
<Badge variant="secondary">Secondary</Badge>
```
## Variants
Use the `variant` prop to switch between the preset badge appearances.
<WidgetExample name="badge-variants" />
## With Icon
Combining Icon and Text child widgets lets an icon and a label express a status or category together. Place the icon before the text for a leading icon, or after it for a trailing icon. Badge lays its children out in a row, keeps a fixed 20px height, and constrains the icon's font size to match the text, so no extra spacing or size classes are needed.
<WidgetExample name="badge-icon" />
## Custom Colors
Use the `color` prop or `ui_badge_set_color()` to apply a named color.
<WidgetExample name="badge-colors" />
## API Reference
<FieldTable name="badge" />