Feedback & Status
Badge
A small status indicator label with clean, modern design.
Preview
Section titled “Preview”<nana-badge variant="primary">New</nana-badge> Installation
Section titled “Installation”The badge ships for all three targets. Pick the tab for your project — the CLI detects which you are on and serves the matching implementation.
npx @nana-tec/ui add badgeLands as src/components/ui/badge/badge.tsx, styled with Tailwind classes that
resolve to the design tokens. Requires Tailwind v4.
npx @nana-tec/ui add badgeLands in src/lib/components/ui/badge/ as Badge.svelte, styled with Tailwind
classes that resolve to the design tokens. Requires Tailwind v4.
Install the package for a versioned dependency:
npm install @nana-tec/ui-componentsOr copy the source in and own it:
npx @nana-tec/ui add badgeimport { Badge } from "@/components/ui/badge";
export function Example() { return ( <> <Badge variant="primary">New</Badge> <Badge variant="success" dot>Live</Badge> <Badge variant="neutral" size="sm">Draft</Badge> </> );}dot prepends a small filled circle in the current colour. Every native
<span> attribute passes through, and it forwards a ref.
<script lang="ts"> import { Badge } from '$lib/components/ui/badge';</script>
<Badge variant="primary">New</Badge><Badge variant="success" dot>Live</Badge><Badge variant="neutral" size="sm">Draft</Badge>dot prepends a small filled circle in the current colour. Every native
attribute passes through via ...rest.
import "@nana-tec/ui-components/badge";<nana-badge variant="primary">New</nana-badge>Classes you pass to the React and Svelte components are merged with
tailwind-merge, so an override wins rather than fighting. See
Using Tailwind.
Variants
Section titled “Variants”<nana-badge variant="primary">Primary</nana-badge>
<nana-badge variant="success">Success</nana-badge>
<nana-badge variant="warning">Warning</nana-badge>
<nana-badge variant="danger">Danger</nana-badge>
<nana-badge variant="info">Info</nana-badge>
<nana-badge variant="neutral">Neutral</nana-badge> The React and Svelte props, read from the components’ own types:
Badge
| Prop | Type | Default |
|---|---|---|
variant | BadgeVariant | 'neutral' |
size | BadgeSize | 'md' |
dot | boolean | false |
children | ReactNode |
Also accepts Omit<HTMLAttributes<HTMLSpanElement>, 'children'>.
Badge
| Prop | Type | Default |
|---|---|---|
variant | BadgeVariant | 'neutral' |
size | BadgeSize | 'md' |
dot | boolean | false |
children | Snippet |
Also accepts Omit<HTMLAttributes<HTMLSpanElement>, 'class'>.
The attribute names, events and CSS hooks below are the Web Components reference.
Properties
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
capsule | capsule | boolean | false | Capsule shape instead of fully rounded |
dot | dot | boolean | false | Show a dot indicator before the text |
interactive | interactive | boolean | false | Makes badge interactive with hover/focus states |
outline | outline | boolean | false | Outline style with transparent background |
pulse | pulse | boolean | false | Pulse animation for the dot (only when dot is true) |
removable | removable | boolean | false | Removable badge with close button |
size | size | BadgeSize | 'md' | Size of the badge |
variant | variant | BadgeVariant | 'neutral' | Visual style variant |
Slots
| Slot | Description |
|---|---|
(default) | Badge text content |
CSS parts
| Part | Description |
|---|---|
::part(badge) | The badge container |
::part(remove-button) | The remove button, when removable |
CSS custom properties
| Property | Description |
|---|---|
--nana-badge-bg | Custom background color |
--nana-badge-color | Custom text color |
--nana-badge-border | Custom border color |
Events
Section titled “Events”| Event | Type |
|---|---|
remove | CustomEvent |
| Slot | Description |
|---|---|
(default) | Badge text content |
CSS Variables
Section titled “CSS Variables”| Variable | Description |
|---|---|
--nana-badge-bg | Custom background color |
--nana-badge-color | Custom text color |
--nana-badge-border | Custom border color |
CSS Parts
Section titled “CSS Parts”| Part | Description |
|---|---|
badge | The badge label |
remove-button | The remove button (when removable) |