Badge
pivot-badge is a small inline label component used to display short, categorized status information. It supports multiple color types (semantic categories such as primary, success, danger, etc.) and three visual styles (solid, subtle, outlined) to suit a variety of UI contexts.
Quick Start
<!-- Default badge — subtle primary -->
<pivot-badge></pivot-badge>
<!-- Solid success badge -->
<pivot-badge pivot-type="success" pivot-style="solid">Active</pivot-badge>
<!-- Outlined danger badge with custom label attribute -->
<pivot-badge
pivot-type="danger"
pivot-style="outlined"
pivot-label="Error"
></pivot-badge>
<!-- Caution badge using slotted content -->
<pivot-badge pivot-type="caution" pivot-style="subtle"
>Needs Review</pivot-badge
>Using the default slot
pivot-badge renders a single, unnamed slot: <slot>${this.label}</slot>. Because pivot-label is used as the slot’s fallback content, the two behave as a pair rather than two independent ways to set text:
- If the badge has slotted content (text or inline elements), that content renders and
pivot-labelis ignored. - If the badge has no slotted content, the browser renders the slot’s fallback content — the current
pivot-labelvalue ("Badge Label"by default).
<!-- Slotted content takes precedence over pivot-label -->
<pivot-badge pivot-type="primary" pivot-style="subtle" pivot-label="Ignored"
>Slotted text</pivot-badge
>
<!-- No slotted content — falls back to pivot-label -->
<pivot-badge
pivot-type="primary"
pivot-style="subtle"
pivot-label="Label fallback"
></pivot-badge>
<!-- No slotted content and no pivot-label override — falls back to the default "Badge Label" -->
<pivot-badge pivot-type="primary" pivot-style="subtle"></pivot-badge>Prefer plain text or short inline elements (e.g. an icon plus text) in the default slot — the badge is sized to its content (inline-size: fit-content) and is not designed to wrap block-level or multi-line content.
Style Variants
pivot-badge supports three visual styles controlled by the pivot-style attribute:
subtle(default) — Lightly tinted background with darker text. Appropriate for low-emphasis labels.solid— Filled background with contrasting text. Use for higher-emphasis status indicators.outlined— Transparent background with a colored border and text. Use for a more neutral appearance that still carries semantic color.
<pivot-badge pivot-type="info" pivot-style="subtle">Info</pivot-badge>
<pivot-badge pivot-type="info" pivot-style="solid">Info</pivot-badge>
<pivot-badge pivot-type="info" pivot-style="outlined">Info</pivot-badge>pivot-style reflects to its attribute, so the current style is always readable/queryable from the DOM (e.g. badge.getAttribute("pivot-style") or a [pivot-style="solid"] CSS selector from outside the component).
Type Variants
The pivot-type attribute maps to a semantic color category. The caution and warning types share the same token set, as do danger and error — warning/error are accepted by the component’s CSS as aliases, but are not part of pivotType’s TypeScript type, so prefer caution/danger when setting the property programmatically in TypeScript.
| Type | Aliases | Semantic Meaning |
|---|---|---|
primary |
— | Brand/default |
neutral |
— | No semantic weight |
success |
— | Positive / completed state |
info |
— | Informational |
caution |
warning |
Attention required |
danger |
error |
Critical / destructive state |
<pivot-badge pivot-type="success">Active</pivot-badge>
<pivot-badge pivot-type="danger">Denied</pivot-badge>
<pivot-badge pivot-type="caution">Pending</pivot-badge>
<pivot-badge pivot-type="neutral">Draft</pivot-badge>Accessibility
pivot-badge renders inline content and does not carry an implicit ARIA role. It is a purely visual element for conveying status or categorization; no ARIA state changes with any property (WCAG 4.1.2 is satisfied trivially — there is no custom role or state to keep in sync).
Screen Reader Behavior
The badge’s text content — either slotted content or the pivot-label fallback — is read inline by screen readers as plain text. Because the badge has no role of its own, it is announced as part of surrounding context, not as a distinct landmark or control.
If a badge conveys standalone information that may not be clear from surrounding context (e.g., a badge appearing next to a user name or action), consider adding a visually hidden label or using aria-label on a containing element to provide fuller context:
<!-- Example: status badge alongside a user name with additional context for assistive technology -->
<span>
Jane Smith
<pivot-badge
pivot-type="success"
pivot-style="subtle"
aria-label="Status: Active"
>Active</pivot-badge
>
</span>If a badge communicates a status change that occurs after the page has loaded (e.g. a badge’s pivot-type/content updates in place to reflect a new state), that update is not automatically announced to assistive technology (WCAG 4.1.3, Status Messages) — pivot-badge has no built-in live region. Wrap the badge in an element with role="status" (or aria-live="polite") if the change needs to be announced.
Color and Contrast
Semantic color variants (success, danger, caution, etc.) use design tokens tuned for accessible contrast ratios within each style. Do not rely on badge color alone to convey information — always ensure the text label within the badge is meaningful (WCAG 1.4.1, Use of Color).
Keyboard Navigation
pivot-badge has no keyboard handlers and responds to no keys. It is not part of the tab order and has nothing to navigate within.
Focus Management
pivot-badge is not interactive and is not focusable — it sets no tabindex and calls no focus methods. It does not participate in keyboard navigation or focus management (WCAG 2.1.1 does not apply, as there is no interactive behavior to make keyboard-operable).
References
API Reference
Props
| Name | Type | Default | Description |
|---|---|---|---|
pivot-label |
string |
"Badge Label" |
The text content displayed in the badge. |
pivot-type |
"primary" | "neutral" | "danger" | "caution" | "success" | "info" |
"primary" |
The color variant of the badge. Supports semantic colors (primary, neutral, success, info, caution, danger), plus the aliases "warning" (for caution) and "error" (for danger). |
pivot-style |
"solid" | "subtle" | "outlined" |
"subtle" |
The visual style of the badge. - "solid": Filled background with contrasting text - "subtle": Light background with darker text - "outlined": Transparent background with colored border and text |
Slots
| Name | Description |
|---|---|
default |
Default slot for badge content |
CSS Custom Properties
| Name | Description |
|---|---|
--__solid-background-color |
Background color for solid variant |
--__solid-text-color |
Text color for solid variant |
--__solid-border-color |
Border color for solid variant |
--__subtle-background-color |
Background color for subtle variant |
--__subtle-text-color |
Text color for subtle variant |
--__subtle-border-color |
Border color for subtle variant |
--__outlined-background-color |
Background color for outlined variant |
--__outlined-text-color |
Text color for outlined variant |
--__outlined-border-color |
Border color for outlined variant |
All types × all styles
<!-- Solid -->
<pivot-badge
pivot-type="primary"
pivot-style="solid"
pivot-label="Primary"
></pivot-badge>
<pivot-badge
pivot-type="neutral"
pivot-style="solid"
pivot-label="Neutral"
></pivot-badge>
<pivot-badge
pivot-type="success"
pivot-style="solid"
pivot-label="Success"
></pivot-badge>
<pivot-badge
pivot-type="info"
pivot-style="solid"
pivot-label="Info"
></pivot-badge>
<pivot-badge
pivot-type="caution"
pivot-style="solid"
pivot-label="Caution"
></pivot-badge>
<pivot-badge
pivot-type="danger"
pivot-style="solid"
pivot-label="Danger"
></pivot-badge>
<!-- Subtle (default) -->
<pivot-badge
pivot-type="primary"
pivot-style="subtle"
pivot-label="Primary"
></pivot-badge>
<pivot-badge
pivot-type="neutral"
pivot-style="subtle"
pivot-label="Neutral"
></pivot-badge>
<pivot-badge
pivot-type="success"
pivot-style="subtle"
pivot-label="Success"
></pivot-badge>
<pivot-badge
pivot-type="info"
pivot-style="subtle"
pivot-label="Info"
></pivot-badge>
<pivot-badge
pivot-type="caution"
pivot-style="subtle"
pivot-label="Caution"
></pivot-badge>
<pivot-badge
pivot-type="danger"
pivot-style="subtle"
pivot-label="Danger"
></pivot-badge>
<!-- Outlined -->
<pivot-badge
pivot-type="primary"
pivot-style="outlined"
pivot-label="Primary"
></pivot-badge>
<pivot-badge
pivot-type="neutral"
pivot-style="outlined"
pivot-label="Neutral"
></pivot-badge>
<pivot-badge
pivot-type="success"
pivot-style="outlined"
pivot-label="Success"
></pivot-badge>
<pivot-badge
pivot-type="info"
pivot-style="outlined"
pivot-label="Info"
></pivot-badge>
<pivot-badge
pivot-type="caution"
pivot-style="outlined"
pivot-label="Caution"
></pivot-badge>
<pivot-badge
pivot-type="danger"
pivot-style="outlined"
pivot-label="Danger"
></pivot-badge>Slotted content vs pivot-label fallback
<!-- Slotted content takes precedence -->
<pivot-badge pivot-type="primary" pivot-style="subtle"
>Slotted text</pivot-badge
>
<!-- pivot-label attribute used as fallback -->
<pivot-badge
pivot-type="primary"
pivot-style="subtle"
pivot-label="Label fallback"
></pivot-badge>
<!-- No content — renders default label "Badge Label" -->
<pivot-badge pivot-type="primary" pivot-style="subtle"></pivot-badge>