Badge
A compact status or count label with semantic tones.
npx @swipeui/cli add badgeWhen to use it
- Status labels such as New, Beta, Paid or Overdue.
- Counts on icons or list rows, such as 3 unread.
- Small category tags in cards.
When not to use it
- Tappable filters. Use Chip.
- Longer messages. Use Alert.
- Tab bar badges; tab bars draw their own from tabBarBadge.
Installation
Run this from your app's root. If SwipeUI isn't set up yet, run npx @swipeui/cli init first; it sets up Uniwind, the theme tokens and the cn helper.
npx @swipeui/cli add badge- Adds
components/swipeui/ui/badge.tsxand 2 shared helpers. - Installs class-variance-authority, uniwind, clsx, tailwind-merge. In Expo apps it uses
npx expo installso versions match your SDK.
Usage
import { Badge } from '@/components/swipeui/ui/badge';
<Badge>New</Badge>
<Badge variant="destructive" accessibilityLabel="3 new messages">3</Badge>Variants are default (bg-primary), secondary, destructive and outline.
API reference
| Prop | Type | Default | Description |
|---|---|---|---|
children | | — | The content. Strings and numbers are wrapped in |
variant? | | | The visual style. |
className? | | — | Classes merged over the variant. |
textClassName? | | — | Classes for the label text. |
soft? | | | Softer semantic surface. |
dot? | | | Leading status dot; the label still carries meaning. |
textTone? | | | The label's tone on the saturated |
style? | | — | Style escape hatch for the container. |
The other View props pass through.
Composition and behavior
- children is the label or count.
- variant is default, secondary, destructive, outline, success, warning or info.
- textClassName styles the text.
Feedback lineup settings
| Prop | Does / default |
|---|---|
children | The content. Strings and numbers are wrapped in Text. |
variant | The visual style. @default 'default' |
className | Classes merged over the variant. |
textClassName | Classes for the label text. |
soft | Softer semantic surface. @default false |
dot | Leading status dot; the label still carries meaning. @default false |
textTone | The label's tone on the saturated destructive fill: dark for stronger contrast, or light for a white count. @default 'dark' |
style | Style escape hatch for the container. |
Filled destructive badges use a saturated colour derived from the destructive token, with a dark foreground from the existing theme. Soft badges retain their semantic tint. Explicit caller styles still win.
Behavior and gestures
- Static; it doesn't respond to touch.
Accessibility
- Give counts an accessibilityLabel that says what they count, such as "3 new messages"; a bare number means little.
- Status words are read as written.
- Tones come with text, so colour is never the only signal.
Motion
- Static on its own; any movement comes from the parent that animates it.
- Static.
Performance
- A tiny view with text; free to use in lists.
Notes for AI
- Choose the variant for meaning: destructive for errors, success, warning, info.
Compatibility
| Runs on | Supported |
|---|---|
| Expo SDK 57 | Yes |
| Expo SDK 58 | Yes |
| React Native CLI (with Expo modules) | Yes |
| Expo Go | Yes |
| iOS | Yes |
| Android | Yes |
This table describes API support and static bundle checks. Native runtime, device accessibility and bare Uniwind compatibility remain pending.