Components
Badge
Display a short count or status beside related content.
Example
Requires React 18.2+ or 19 and shared styles. See setup.
Default
Loading preview…
Code
'use client';
import { Badge } from '@swiftuijs/ui';
export default function Example() {
return (<Badge>5</Badge>);
}Variants
Badge supports different visual variants:
Usage and limitations
- Variants are
primary,success,warning, anderror; content can be text or a number. - Keep content short and place it consistently beside the item it describes. Do not communicate status through color alone.
- Supply an accessible label when the number or icon needs context; customize appearance with
style.
More examples
Styles
API reference
| Prop | Type | Required | Description |
|---|---|---|---|
children | ReactNode | Yes | Badge content (text or number) |
variant | 'default' | 'primary' | 'success' | 'warning' | 'error' | No | Badge style variant Default: 'default' |
style | IBaseComponent['style'] | No | Custom CSS style (overrides variant) |
Inherits additional props from Omit<IBaseComponent, 'style'>.