Badge
Data displayA short label for a status, a category or a count: <Badge> with a variant colour (primary, secondary, neutral, outline, or a status: info, success, warning, error). An icon before the text is sized for it. With the child snippet it renders a link or another element.
import { Badge } from '@limerdev/zest'; Use for
An invoice's status in a table row, a role beside a name, a count beside a tab.
Don't
Something to click that does an action: use
Button (size="sm"). A long message: use Alert. Colour alone for meaning: the text must say it.Examples
Variants
The variants: primary by default, the other theme colours and the statuses.
New Secondary Neutral Draft Sent Paid Due soon Overdue
<script lang="ts">
import { Badge } from '@limerdev/zest';
</script>
<div class="flex flex-wrap gap-2">
<Badge>New</Badge>
<Badge variant="secondary">Secondary</Badge>
<Badge variant="neutral">Neutral</Badge>
<Badge variant="outline">Draft</Badge>
<Badge variant="info">Sent</Badge>
<Badge variant="success">Paid</Badge>
<Badge variant="warning">Due soon</Badge>
<Badge variant="error">Overdue</Badge>
</div> Icons and links
An icon before the text is sized for the badge; the child snippet makes it a link.
Verified 12 invoices
<script lang="ts">
import { Badge } from '@limerdev/zest';
import BadgeCheck from '@lucide/svelte/icons/badge-check';
</script>
<div class="flex flex-wrap gap-2">
<Badge variant="success"><BadgeCheck aria-hidden="true" /> Verified</Badge>
<Badge variant="outline">
{#snippet child({ props })}
<a href="#invoices" {...props}>12 invoices</a>
{/snippet}
</Badge>
</div> Props
Every part also takes class (merged over its defaults), ref (bindable: the element), children, and child (a snippet that
renders your own element, with props to spread on it).
Badge
| Prop | Type | Default | Description |
|---|---|---|---|
| variant | "primary" | "secondary" | "neutral" | "error" | "outline" | "info" | "success" | "warning" | 'primary' | The colour: primary, secondary, neutral, outline, or a status (info, success, warning, error). |