Status Badge
v0.1.5Severity badge with solid and translucent-chip appearances, plus reusable severity color helpers.
Install
npx shadcn@latest add @signalos/status-badgeRequires a configured @signalos registry and a valid SIGNALOS_REGISTRY_TOKEN - get access. Registry dependencies (@signalos/tokens, @signalos/utils, @signalos/badge) are pulled automatically.
Preview
Example & code
status-badge.example.tsx
// Example: severity badges plus the standalone helpers in a custom cell.
import {
severityBorderClass,
StatusBadge,
} from "@/components/widgets/status-badge/StatusBadge"
import type { Severity } from "@/components/widgets/status-badge/StatusBadge.types"
const incidents: Array<{ id: string; title: string; severity: Severity }> = [
{ id: "INC-31", title: "Queue backlog above threshold", severity: "high" },
{ id: "INC-29", title: "Nightly sync completed late", severity: "medium" },
{ id: "INC-27", title: "New connector online", severity: "info" },
]
export default function Example() {
return (
<div className="flex flex-col gap-3">
{incidents.map((incident) => (
<div
key={incident.id}
// The border helper works anywhere - cards, rows, callouts:
className={`flex items-center justify-between rounded-lg border border-border border-l-2 bg-card p-3 ${severityBorderClass(incident.severity)}`}
>
<div className="flex items-center gap-3">
<span className="font-mono text-xs text-muted-foreground">
{incident.id}
</span>
<span className="text-sm text-foreground">{incident.title}</span>
</div>
<StatusBadge severity={incident.severity} />
</div>
))}
</div>
)
}
Props
StatusBadgeProps
| Prop | Type | Default | Description |
|---|---|---|---|
| severity | Severity | null | undefined | - | Severity driving color and default label. null/undefined renders a neutral "UNSET" badge. |
| children | ReactNode | - | Custom label; defaults to the uppercased severity. |
| appearance | "solid" | "chip" | undefined | "solid" | Visual style: "solid" uses badge tokens; "chip" uses the translucent 15%-tint style used inside stat cards and tables. |
| className | string | undefined | - | |
| data-testid | string | undefined | - | Test identifier rendered as `data-testid` on the root element. |
Supporting types
export type Severity = | "critical" | "high" | "medium" | "low" | "info" | "active" | "inactive" | "error"
Changelog
0.1.5
- Fix cross-item imports to use canonical @/components paths; add missing signalos.category to manifests.
status-badge
0.1.4
- Extend
Severitytype with"active","inactive", and"error"values. - Map new values through
severityLabel,severityToVariant,severityBadgeClasses, andseverityBorderClassusing semantic tokens (bg-bg-success/error/muted,border-l-status-*).
0.1.3
- Add a
data-testidpassthrough on the root element so consumers can target the badge directly.
0.1.2
- Use semantic status tokens (text-text-error, bg-bg-warning, border-border-, bg-status-) instead of raw palette scales so client theme overrides restyle status colors.
0.1.1
- Content sync fix to bring source in line with published registry payload.
0.1.0
- Initial release. Severity helpers lifted from
signal-core-uislot-card-utils.tsand genericized: raw Tailwind palette classes (red/yellow/green/blue) normalized to token scales (error-*,warning-*,success-*,info-*); domainBlackboardSeverityreplaced with a widget-ownedSeveritytype. - Component builds on the
@signalos/badgeprimitive withsolidandchipappearances.