Badges are small status indicators used next to labels, menu items, and avatars.
Setup
<script lang="ts">
import { Badge } from '.';
</script> Default badge
Default
Gray
Red
Green
Yellow
Indigo
Purple
Pink
<script>
import { Badge } from '.';
</script>
<Badge>Default</Badge>
<Badge color="gray">Gray</Badge>
<Badge color="red">Red</Badge>
<Badge color="green">Green</Badge>
<Badge color="yellow">Yellow</Badge>
<Badge color="indigo">Indigo</Badge>
<Badge color="purple">Purple</Badge>
<Badge color="pink">Pink</Badge> Large badge
Default
Gray
Red
Green
<Badge large>Default</Badge>
<Badge large color="gray">Gray</Badge>
<Badge large color="red">Red</Badge>
<Badge large color="green">Green</Badge> Pill badge
Default
Red
Green
Indigo
<Badge rounded>Default</Badge>
<Badge rounded color="red">Red</Badge>
<Badge rounded color="green">Green</Badge>
<Badge rounded large color="indigo">Indigo</Badge> Bordered badge
Default
Red
Green
<Badge border>Default</Badge>
<Badge border color="red">Red</Badge>
<Badge border color="green">Green</Badge> Badge as link
<Badge href="/docs">Docs</Badge> Dismissable badge
Dismiss me
<Badge dismissable>Dismiss me</Badge> Colors
Theme color tokens: primary, secondary, gray, red, orange, amber, yellow, lime, green, emerald, teal, cyan, sky, blue, indigo, violet, purple, fuchsia, pink, rose.
Composition notes
largemaps to the themesize: 'large'variant (smallis default).- With
href, content is wrapped in a link;targetis forwarded to that anchor. - Bind
badgeStatusfor controlled dismiss; optionaltransition/paramsanimate removal.
Props
BadgeProps
| Prop | Type | Default | Description |
|---|---|---|---|
children | Snippet | — | Badge label |
color | primary | secondary | gray | red | orange | amber | yellow | lime | green | emerald | teal | cyan | sky | blue | indigo | violet | purple | fuchsia | pink | rose | primary | Theme color |
large | boolean | false | Larger text/padding |
rounded | boolean | false | Pill shape (rounded-full) |
border | boolean | false | Show border |
dismissable | boolean | false | Show close button |
badgeStatus | boolean | true | Bindable visibility |
closeAriaLabel | string | — | Accessible label for close |
icon | Snippet | — | Leading icon |
href | string | — | Render as link |
target | HTMLAnchorAttributes['target'] | — | Link target |
transition | TransitionFunc | — | Dismiss transition |
params | ParamsType | — | Transition params |
class | ClassValue | — | Extra classes |
…rest | div attrs (except color) | — | Forwarded to the root |
Snippets
| Snippet | Description |
|---|---|
children | Label text / nodes |
icon | Leading icon |