- v2.14.0-stablePromoted across all production edgesRecommended
- v2.15.0-rc.2Canary validation in staging clusterPreview
- v2.13.4-ltsSecurity maintenance window ends Dec 31Deprecated
GhostBadge
GhostBadge is a compact, non-interactive label for short status and metadata values. Import it from @ghostvue/themes for the default visual treatment. To style your own badges, see Advanced: headless composition.
Release channels
Badge variants and semantic tones marking release channel status inside a card.
Each release channel row ends in a themed GhostBadge from @ghostvue/themes. The status is in the badge text: Recommended, Preview and Deprecated. The solid, soft and outline variants and the accent, neutral and danger tones only add visual emphasis, so the list still reads correctly in grayscale, in forced colors and to a screen reader.
Basic use
The root is a native <span>. Slot text is the accessible name. The component adds no role and is not a tab stop, so a screen reader reads the badge as part of its row ("v2.13.4-lts … Deprecated").
Variants and tones
Visual props on the @ghostvue/themes wrapper.
Importing the themed component loads the default stylesheet. Visual props exist only on this wrapper:
@ghostvue/themes adds these to the headless GhostBadge API, which it forwards:
| Prop | Type | Default | Description |
|---|---|---|---|
variant | 'solid' | 'soft' | 'outline' | 'ghost' | "soft" | Visual treatment. The default omits data-variant so CSS can treat a missing hook as soft. |
tone | 'accent' | 'neutral' | 'danger' | 'success' | 'warning' | "neutral" | Semantic color intent, independent of variant and not a status vocabulary. success and warning use the status tokens and are Badge-only; Button tones stay accent, neutral, and danger. The default omits data-tone. |
size | 'sm' | 'md' | "sm" | Compact type and padding. The default omits data-size so CSS can treat a missing hook as sm. Does not use control minimum sizes. |
Defaults omit the matching data-* attribute so CSS can treat a missing hook as soft / neutral / sm.
tone picks a color, not a status. Put the status in the slot (Paid, Overdue) and choose the tone that matches it:
neutralfor drafts, counts, and plain metadata.successfor settled or healthy states, such as paid or published.warningfor states that need attention soon, such as due soon or refunded.dangerfor failures and overdue items.accentfor brand emphasis, such as a featured or recommended item.
Do not use accent to mean success. It follows the brand color, so it turns purple in Vibrant and is close to neutral in Mono. success and warning take their colors from the --ghost-status-success-* and --ghost-status-warning-* tokens, so they look the same whatever the accent is. They have no gradient in the solid variant.
Badge has two tones that themed GhostButton does not: success and warning. There is no info tone. Domain status belongs in the text (and in any data-* attributes you own).
Themed badges do not use control minimum sizes. Those minima are touch targets and would make table-cell badges too tall. Applications that wrap a badge in a control own that control's target size.
Icons
Optional decorative icons live in the default slot and opt into theme sizing with data-part="icon". Hide them from assistive technology.
Optional decorative icon marked data-part=icon.
Icon-only badges need real text, typically via GhostVisuallyHidden. Do not put aria-label on the badge span: a role-less <span> cannot host it. Color and iconography must not be the only encoding of meaning.
Table cells, counts, and filters
Cell statuses, numeric counts, and active-filter summaries are the first DataTable uses. Keep the strings short.
Cell statuses, counts, and active-filter summaries.
When not to use it
- Anything clickable, toggleable, or dismissible. Use
GhostButtonor a later chip/filter control. This component does not addtabindex, click handling, or a close affordance. - As a live region. Do not set
role="status"on the badge. If a change must be announced, putaria-liveon a container you own. - As the only encoding of status. A red unlabeled mark is not a badge.
Accessibility and environment behavior
Assistive technology encounters ordinary phrasing content. The badge is not a tab stop and adds no keyboard behavior. SSR markup is deterministic from slot content and themed visual props. Setup does not read browser globals.
See the GhostBadge specification for the complete behavior and compatibility contract.
Advanced: headless composition
For teams that bring their own design system, the headless GhostBadge from @ghostvue/vue renders the same <span> with no visuals.
Headless badge
Unstyled compact status text.
Composable
useGhostBadge returns rootProps for a <span> you render yourself. The GhostBadge reference page renders the badge/composable example with its source.
Styling
The unstyled component renders one native <span> with class ghost-badge and data-part="root". There is no data-state hook and no internal wrapper to target.
.ghost-badge [data-part='icon'] {
/* Optional decorative icon. */
}You can also import the stylesheet and wrap unstyled badges in .ghost-theme when you want a region of headless components to pick up the defaults. See the default theme guide for tokens and overrides.
API
| Slot | Slot props | Description |
|---|---|---|
default | — | Short status or metadata text and optional decorative icon content. Icon-only use needs real hidden text (GhostVisuallyHidden), not aria-label on the span. |
The unstyled component declares no behavioral props. All native span attributes and event listeners fall through to the root. The default slot is the only content slot. The component does not generate an id; pass one as a native attribute when you need it. There is no model.