Skip to content

Badge

In review
Live · web

Live: drive the inbox count (0 → dot · 1-99 → number · 100+ → 99+)

Bell shows 3 unread. The badge pops in on change, frozen under reduced-motion.

Anchored: pinned to a host corner (count + dot), ringed to punch out

count
overflow
PMdot · avatar
dot · icon

Standalone: inline, named for assistive tech

11299999+

Solid label: filled hue + contrast label (accent · info · success · warning · danger · neutral)

accentinfosuccesswarningdangerneutral

Soft label: low-alpha tint + hue label (the inline pill idiom)

accentinfosuccesswarningdangerneutral

Sizes: sm · md (count, dot, and label)

8beta
sm
8beta
md

Language: the hue-free code tag (a language is metadata, never a status color · always lowercase mono)

Language · app-configured color (optional): the app supplies its own mapping via the color prop

// Web: React, consuming @dizyx/nockerl-tokens. (Web is the laggard platform; this is the
// canonical API the published @dizyx/nockerl-react package is intended to expose. It unifies
// the shipped idioms: a count/dot overlay (Compose BadgedBox) + a tonal status pill.)
import { NockerlBadge } from '@dizyx/nockerl-react';
export function InboxBell({ unread }: { unread: number }) {
return (
<button aria-label={unread > 0 ? `Inbox, ${unread} unread` : 'Inbox, unseen activity'}>
<BellIcon />
{/* anchored: a count → "99+" overflow, falling back to a bare dot at 0 */}
{unread > 0 ? <NockerlBadge count={unread} tone="danger" anchored /> : <NockerlBadge dot tone="danger" anchored />}
</button>
);
}
// standalone status pills (passive, so name them for assistive tech)
<NockerlBadge label="research" tone="warning" variant="soft" />
<NockerlBadge count={12} tone="accent" ariaLabel="12 items" />

A code language is metadata, never status, so its tag carries no hue. NockerlLanguageBadge is the first-class, hue-free tag: a quiet lowercase monospace pill (neutral soft wash + muted ink) shared by the CodeBlock header, the DiffViewer header, and the Markdown code fence, so the tag reads identically everywhere. The label runs through the shared nockerlLanguageLabel contract (trim + lowercase, blank → nothing). It is byte-identical to the native rails, so 'TypeScript' renders typescript on every surface.

PropTypeDefaultDescription
languagestring | nullThe language name in any casing (e.g. 'TypeScript'). Normalized to a lowercase tag by the shared nockerlLanguageLabel contract; a blank / absent value renders nothing.
colorstringOPTIONAL app-side tag color: tints the soft wash + the lettering via NockerlBadge's arbitrary-color path. The APP owns the language→color mapping; the framework never hardcodes one. Unset = the neutral default.
sizeNockerlBadgeSize'sm'Badge scale. Defaults to sm (the code-header pill size).

Also accepts the native <span> attributes (e.g. onClick, disabled, id, aria-*, data-*), forwarded straight through, plus a forwarded ref.

PropTypeDefaultDescription
countnumberNumeric count. Clamped to max, rendering e.g. 99+ past it.
labelstringFree-text label (use instead of count for a status badge).
dotbooleanfalseRender a bare dot: no number, no text (the "unseen" indicator).
toneNockerlBadgeTone'accent'Status / accent hue. Cyan is accent; the rest are warm status + neutral.
variantNockerlBadgeVariant'solid'solid = filled hue + contrast label; soft = low-alpha tint + hue label.
colorstringOverride the tone hue with an ARBITRARY color (e.g. a per-language code color the 6 fixed tones can't express). Drives the soft tint/label/border (or the solid fill). Falls back to tone when unset.
monobooleanfalseRender the label in the monospace family (for code / file-type / version pills).
sizeNockerlBadgeSize'md'NockerlBadge scale.
maxnumber99Overflow ceiling for count (e.g. 99 → 99+).
anchoredbooleanfalsePin to the parent host's top-right corner (overlapping, ringed). The parent must be the positioned host (the demo's Anchored wrapper provides it). Else the badge renders inline.
ariaLabelstringAccessible name announced for the badge when it stands alone (e.g. "3 unread"). When the badge is anchored, name the HOST instead and leave this unset. The count is decorative there.

Also accepts the native <span> attributes (e.g. onClick, disabled, id, aria-*, data-*), forwarded straight through, plus a forwarded ref.