Badge
---import { Badge } from "@/components/starwind/badge";---
<Badge tone="primary-accent" appearance="soft">Introducing Starwind UI v3</Badge>import { Badge } from "@/components/starwind/badge";
export function Example() { return ( <div className="flex flex-wrap items-center gap-2"> <Badge tone="primary-accent" appearance="soft">Introducing Starwind UI v3</Badge> </div> );}Installation
pnpx starwind@latest add badgenpx starwind@latest add badgeyarn dlx starwind@latest add badgeFramework Availability
Astro Available React AvailableBadge is available for Astro and React.
Usage
Use tone to choose the semantic color and appearance to choose how strongly that color is presented. They can be combined independently, giving you more control than the original variant prop.
Tone and appearance
The available tones are neutral, primary, primary-accent, secondary, secondary-accent, info, success, warning, and error. Each tone supports solid, soft, outline, text, and frosted appearances.
solid
soft
outline
text
frosted
---import { Badge } from "@/components/starwind/badge";---
<Badge tone="primary" appearance="solid">Primary</Badge><Badge tone="primary-accent" appearance="soft">Primary accent</Badge><Badge tone="success" appearance="outline">Success</Badge><Badge tone="warning" appearance="text">Warning</Badge><Badge tone="info" appearance="frosted">Info</Badge>Providing either tone or appearance opts into the composable styling API. When one is omitted, the component uses neutral for the tone or soft for the appearance.
Eyebrow
Use eyebrow for compact labels that need an uppercase treatment with wider letter spacing. It can be combined with every tone, appearance, and size.
---import { Badge } from "@/components/starwind/badge";---
<Badge tone="primary-accent" appearance="text" size="sm" eyebrow>Small eyebrow</Badge><Badge tone="primary-accent" appearance="text" size="md" eyebrow>Medium eyebrow</Badge><Badge tone="primary-accent" appearance="text" size="lg" eyebrow>Large eyebrow</Badge>Size and icons
---import { Badge } from "@/components/starwind/badge";import Mail from "@tabler/icons/outline/mail.svg";---
<Badge tone="primary-accent" appearance="soft" size="sm"><Mail />Small</Badge><Badge tone="primary-accent" appearance="soft" size="md"><Mail />Medium</Badge><Badge tone="primary-accent" appearance="soft" size="lg"><Mail />Large</Badge>Link
Provide an href to render the Badge as an <a> element. Link badges receive hover styles suited to their selected appearance.
---import { Badge } from "@/components/starwind/badge";---
<Badge href="#link" tone="primary" appearance="solid">Primary</Badge><Badge href="#link" tone="secondary" appearance="solid">Secondary</Badge><Badge href="#link" tone="primary-accent" appearance="soft">Primary accent</Badge><Badge href="#link" tone="success" appearance="outline">Success</Badge>Legacy variants
The variant prop is still supported to avoid breaking changes. For new usage, prefer tone and appearance, which separate semantic color from visual emphasis. If tone or appearance is provided, the composable styling API takes precedence over variant.
---import { Badge } from "@/components/starwind/badge";---
<Badge variant="default">Default</Badge><Badge variant="primary">Primary</Badge><Badge variant="secondary">Secondary</Badge><Badge variant="outline">Outline</Badge><Badge variant="ghost">Ghost</Badge><Badge variant="info">Info</Badge><Badge variant="success">Success</Badge><Badge variant="warning">Warning</Badge><Badge variant="error">Error</Badge>API Reference
Styled Component API
These props are added or materially changed by the installed Astro styled component. Standard HTML attributes remain available through the inherited interfaces noted below. Follow the Primitive and Runtime links for lower-level behavior props.
Badge
Inherits a attributes. Omits `type`.
Inherits div attributes.
Contains the following additional props:
appearance "solid" | "soft" | "outline" | "text" | "frosted" —
- Description
- Selects whether the Badge uses solid, soft, outlined, text, or frosted chrome.
- Classification
- Styled variant
eyebrow boolean false
- Description
- Applies uppercase tracking for compact eyebrow labels.
- Classification
- Styled variant
size "sm" | "md" | "lg" "md"
- Description
- Selects the component's visual size.
- Classification
- Styled variant
tone "neutral" | "primary" | "primary-accent" | "secondary" | "secondary-accent" | "info" | "success" | "warning" | "error" —
- Description
- Selects the semantic color family used by composed Badge appearances.
- Classification
- Styled variant
variant "default" | "primary" | "secondary" | "outline" | "ghost" | "info" | "success" | "warning" | "error" "default"
- Description
- Selects the component's visual variant.
- Classification
- Styled variant
Changelog
v1.5.0
- Added contract-generated Astro and React implementations.
- Added
tone,appearance, andeyebrowtreatments while preserving the legacyvariantAPI for backwards compatibility.
v1.4.3
- Refactor tailwind variants functions into separate
variants.tsfile
v1.4.0
- Add automatic styling for SVGs within badges
v1.3.0
- Style and focus state updates
v1.2.0
- Add a
data-slotattribute to all components to enable global styling updates
v1.1.1
- Adjust component to use type
VariantPropsfromtailwind-variants. This provides greater type safety and cleans up component frontmatter.
v1.1.0
tailwind-variantsnow implemented. This usestailwind-mergeunder the hood to merge Tailwind classes without style conflicts, allowing you to override any existing classes using the “class” prop.