Badge

Display

A compact inline label with 6 semantic variants, 3 sizes, dot indicator, count overflow, and a dismissible variant.

GitHub

Installation

bash
1
npx native-mate add badge

Examples

#FAFAFA
Radius100%

Usage

tsx
1
2
3
4
5
6
import { Badge } from '~/components/ui/badge'

<Badge>Default</Badge>
<Badge variant="success" dot>Active</Badge>
<Badge variant="destructive" count={5} />
<Badge variant="secondary" onDismiss={() => {}} size="lg">Dismissible</Badge>

Props

PropTypeDefaultDescription
variant"default" | "secondary" | "outline" | "success" | "destructive" | "warning""default"Visual variant.
size"sm" | "md" | "lg""md"Controls padding and font size.
dotbooleanfalseShows a coloured dot before the label.
countnumberNumeric count to display instead of children.
maxCountnumber99When count exceeds this, shows "{maxCount}+".
onDismiss() => voidWhen provided, shows a × button to dismiss the badge.
childrenReact.ReactNodeBadge label content.

Example

tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { Badge } from '~/components/ui/badge'
import { View } from 'react-native'

export function BadgeExamples() {
  return (
    <View style={{ gap: 12, padding: 16 }}>
      <View style={{ flexDirection: 'row', flexWrap: 'wrap', gap: 8 }}>
        <Badge>Default</Badge>
        <Badge variant="secondary">Secondary</Badge>
        <Badge variant="outline">Outline</Badge>
        <Badge variant="success" dot>Active</Badge>
        <Badge variant="destructive" dot>Failed</Badge>
        <Badge variant="warning">Warning</Badge>
      </View>
      <View style={{ flexDirection: 'row', gap: 8 }}>
        <Badge variant="destructive" count={3} />
        <Badge variant="default" count={150} maxCount={99} />
      </View>
    </View>
  )
}