Add this component

npx zentauri-ui add http-status-badge

Accessibility notes

Keyboard accessible by default with semantic markup, visible focus treatment, and tokenized states. Add descriptive labels for icon-only or decorative usage.

Dependency notes

Check Installation for shared peers. This component keeps styling in Tailwind classes and the --zui-* token contract.

Data display

HTTP Status Badge for surfacing response codes

Use the HTTP status badge to render any HTTP status code as a compact, color-coded label. The tone is derived from the status class — 1xx is informational, 2xx success, 3xx redirect, 4xx client error, 5xx server error — and the code is paired with a known reason phrase. Choose between solid, soft, and outline fill styles and three sizes.

200OK301Moved Permanently404Not Found500Internal Server Error

HTTP status badge playground

Pick a status code, fill style, and size to preview the badge live. The tone color is derived from the status class, toggle the reason phrase on or off, and use Show output / Show code to copy the matching snippet.


200OK

All appearances

Every fill style across the status classes. Click any card to load its appearance into the playground above.

solid
100Continue200OK301Moved Permanently404Not Found500Internal Server Error
soft
100Continue200OK301Moved Permanently404Not Found500Internal Server Error
outline
100Continue200OK301Moved Permanently404Not Found500Internal Server Error

Tone per status class

One representative code per HTTP status class, each resolving to its semantic tone.

1xx Informational100Continue
2xx Success200OK
3xx Redirect301Moved Permanently
4xx Client Error404Not Found
5xx Server Error500Internal Server Error

Http Status Badge API

Generated from the package prop types and variant definitions.

HttpStatusBadge

HttpStatusBadgeProps

Variants

PropTypeDefault
appearance
outlinesoftsolid
soft
size
lgmdsm
md

Behavior

PropTypeDefault
showTextShow the reason phrase next to the code. Defaults to true.boolean | undefinednone
status*The HTTP status code to render (e.g. 200, 404, 503).numbernone
statusTextOverride the reason phrase. Defaults to a known phrase for the code, or the tone label.string | undefinednone
Inherited HTML props
PropTypeDefault
classNamestring | undefinednone
idstring | undefinednone
onClickMouseEventHandler<HTMLSpanElement> | undefinednone
styleCSSProperties | undefinednone
titlestring | undefinednone

HttpStatusBadgeVariant

HttpStatusBadgeVariantProps

Behavior

PropTypeDefault
appearance'outline' | 'solid' | 'soft' | null | undefinednone
size'md' | 'sm' | 'lg' | null | undefinednone
CSS variable overrides

HTTP Status Badge CSS variables

Override these HTTP status badge variables on :root, a theme selector, or a component wrapper. Tokens are grouped by tone (info, success, redirect, client-error, server-error, neutral) and fill style (solid, soft, outline).

72 variables

Pattern: --zui-<component>-<slot?>-<variant?>-<property>-<state?>-dark?

:root {
  --zui-http-status-badge-info-solid-bg: #0284c7;
  --zui-http-status-badge-info-solid-fg: #ffffff;
  --zui-http-status-badge-info-soft-bg: #e0f2fe;
  --zui-http-status-badge-info-soft-fg: #075985;
  --zui-http-status-badge-info-outline-border: #0284c7;
  --zui-http-status-badge-info-outline-fg: #075985;
  --zui-http-status-badge-success-solid-bg: #16a34a;
  --zui-http-status-badge-success-solid-fg: #ffffff;
  --zui-http-status-badge-success-soft-bg: #dcfce7;
  --zui-http-status-badge-success-soft-fg: #15803d;
  --zui-http-status-badge-success-outline-border: #16a34a;
  --zui-http-status-badge-success-outline-fg: #15803d;
  --zui-http-status-badge-redirect-solid-bg: #2563eb;
  --zui-http-status-badge-redirect-solid-fg: #ffffff;
  --zui-http-status-badge-redirect-soft-bg: #dbeafe;
  --zui-http-status-badge-redirect-soft-fg: #1d4ed8;
  --zui-http-status-badge-redirect-outline-border: #2563eb;
  --zui-http-status-badge-redirect-outline-fg: #1d4ed8;
  --zui-http-status-badge-client-error-solid-bg: #d97706;
  --zui-http-status-badge-client-error-solid-fg: #ffffff;
  --zui-http-status-badge-client-error-soft-bg: #fef3c7;
  --zui-http-status-badge-client-error-soft-fg: #b45309;
  --zui-http-status-badge-client-error-outline-border: #d97706;
  --zui-http-status-badge-client-error-outline-fg: #b45309;
  --zui-http-status-badge-server-error-solid-bg: #dc2626;
  --zui-http-status-badge-server-error-solid-fg: #ffffff;
  --zui-http-status-badge-server-error-soft-bg: #fee2e2;
  --zui-http-status-badge-server-error-soft-fg: #b91c1c;
  --zui-http-status-badge-server-error-outline-border: #dc2626;
  --zui-http-status-badge-server-error-outline-fg: #b91c1c;
  --zui-http-status-badge-neutral-solid-bg: #475569;
  --zui-http-status-badge-neutral-solid-fg: #ffffff;
  --zui-http-status-badge-neutral-soft-bg: #f1f5f9;
  --zui-http-status-badge-neutral-soft-fg: #334155;
  --zui-http-status-badge-neutral-outline-border: #94a3b8;
  --zui-http-status-badge-neutral-outline-fg: #334155;
}

/* Dark theme variables follow the same names with -dark appended. */
.dark {
  --zui-http-status-badge-info-solid-bg-dark: #0ea5e9;
  --zui-http-status-badge-info-solid-fg-dark: #082f49;
}

What it does

The component maps each status code to a semantic tone by extracting the hundreds-class of the number — 1xx resolves to info, 2xx to success, 3xx to redirect, 4xx to client error, 5xx to server error, and anything outside 100–599 to neutral. The tone drives the badge's background, text, and border colors across solid, soft, and outline fill variants. A built-in lookup table pairs the code with its standard reason phrase, with an override via the statusText prop for custom or uncommon codes. The component renders a single span that composes inline with other text, spreading any extra props onto the DOM element for styling or testing hooks.

Common use cases

  • Annotate API responses and request logs in a debugging or admin panel.
  • Show endpoint health and last-response codes in a dashboard.
  • Render webhook delivery and retry status in an activity feed.
  • Document expected status codes in API reference tables and developer tooling.

Composition and API

Pass a status code through the status prop. The badge derives a semantic tone from the status class and renders the code alongside a reason phrase resolved from a built-in table of common codes (200 OK, 404 Not Found, 503 Service Unavailable, and more). statusText overrides the phrase for uncommon or custom codes, showText hides the phrase to render the code on its own, appearance selects the solid, soft, or outline fill style, and size scales the padding and text. The component renders a single span and spreads any remaining props onto it, so it composes inline anywhere text or other badges live. It exports httpStatusTone and httpStatusText helpers for deriving the same tone and phrase outside the component.

Accessibility

The badge renders as a plain span carrying a data-slot attribute for styling and testing and a data-tone attribute reflecting the resolved status class, so color is never the only signal — the numeric code and reason phrase are always part of the accessible text. Because color encodes meaning, keep showText enabled (or provide your own adjacent label) wherever the tone alone would be ambiguous. Tone palettes ship light and dark variants tuned for contrast.

Next.js integration notes

HttpStatusBadge ships no framer-motion and has no animated entry — it is a static, presentational component safe to render in any Server or Client Component tree. It renders deterministically from the status prop, so server and client output match and there is no hydration mismatch. Import it from @zentauri-ui/zentauri-components/ui/http-status-badge.

FAQ

How is the tone color chosen?

The tone is derived from the status class: 1xx resolves to info, 2xx to success, 3xx to redirect, 4xx to client error, 5xx to server error, and anything outside 100–599 to neutral. You never set the color directly — pass the status code and the badge maps it for you.

Can I show a custom or unknown status code?

Yes. Any number works. Codes in the built-in table render their standard reason phrase; unknown codes fall back to the tone's human label (for example Client Error). Pass statusText to override the phrase with your own.

Can I render just the code without the reason phrase?

Set showText={false} to render only the numeric code. The tone color and data-tone attribute still apply.

Does it need framer-motion?

No. The HTTP status badge is static and presentational with no animated entry, so it ships zero framer-motion and adds no motion dependency to your bundle.

How do I theme the colors?

Override the --zui-http-status-badge-* CSS variables (per tone and fill style) on :root, a theme selector, or a wrapper. Each variable ships a light fallback and a paired -dark variant for dark mode.