Susegad UI Accessibility GitHub

How this site looks

The view settings need JavaScript. Every page reads well without them.

Mood

The same pages, in three moods.

Theme

Components

Badge

A word or two of status. The text is the meaning, a distinct shape per tone backs it up, colour comes last. Quiet is text with a hairline rule; warm is a hand-inked outline in the tone's ink; playful is a chip of colour with a kolam flower on the corner.

quiet warm playful

Open the live demo npx @susegad/cli add badge

Stands on: Core, Core: components, Engine, Tokens

The prompt

the prompt

A word or two of status beside the thing it describes: Paid, Draft, Overdue, Saving.

The word is the meaning. A small shape for each tone backs it up for anyone who cannot tell the colours apart, and colour comes last.

<link rel="stylesheet" href="susegad/components/badge/badge.css">
<script type="module" src="susegad/components/badge/badge.js"></script>

<sg-badge tone="success">Paid</sg-badge>
<sg-badge tone="warning">Deposit due</sg-badge>
<sg-badge tone="info" busy>Saving</sg-badge>
AttributeValuesWhat it does
toneneutral, accent, success, warning, danger, infoThe ink and the shape: a ring, a diamond, a tick, a triangle, a cross, a circled i.
busypresent or absentThe thing is still happening. The words must say so ("Saving", "Checking payment"); the mark moves only in warm and playful.
seedany word or numberThe hand-inked outline in warm. Defaults to the text.

The prompt

Make a status badge web component that is just text: <sg-badge tone="success">Paid</sg-badge>. Never let colour carry the meaning alone. Put a small shape before the words, a different outline for each tone (a ring for neutral, a diamond for accent, a tick for success, a triangle with a bar for warning, a cross for danger, a circled i for info), drawn as a CSS mask on an empty pseudo-element so a screen reader reads only the words. Without JavaScript, show the words in the text colour, the shape in the tone's colour, and a hairline rule around them. Give it three registers. Quiet: exactly that, and nothing moves. Warm: replace the rule with a hand-inked outline in the tone's ink, drawn twice like a nib going round, nudged by seeded noise and closed with a small overlap where the pen passes its start; fit it to the badge's size and redraw when the words change. Playful: fill the badge with the tone as a rounded chip, set the words in the page colour on it, and stick a tiny kolam flower on the top-right corner like a sticker, so it reads as ornament and never as a button. When a badge is busy, breathe the shape slowly in warm and turn the kolam in playful, pause both off screen, and keep everything still under reduced motion. Check that the chip's text meets 4.5:1 on its fill in every palette and theme.

Words to code

When you sayTechniqueWhat happens
never let colour carry the meaning aloneredundancyThe word always carries the meaning. ICONS holds six outlines on a 12 × 12 grid, all different, and a test checks they stay different and that badge.css carries exactly those shapes.
a CSS mask on an empty pseudo-elementnative first::before { content: ""; mask: var(--sg-badge-icon) }. With no content text there is nothing for assistive tech to read twice, and it works with no JavaScript.
drawn twice like a nib going round … closed with a small overlapnoiseinkOutline(w, h, seed) resamples a rounded rectangle every 4 px and pushes each point out from the centre by seeded Perlin noise, scaled by the register's --sg-wobble. The second pass is finer, offset and fainter. The path runs a few points past its start.
fit it to the badge's sizelayoutA ResizeObserver redraws the path at the badge's fractional size, with preserveAspectRatio="none". A viewBox a fraction off scaled the whole outline in towards the words.
like a sticker … never as a buttonaffordanceA trailing icon on a chip reads as "remove" or "add". The kolam flower sits on the corner, overlapping the edge, where controls never go.
breathe … turn … pause both off screencalmbusyMotion(motion) returns nothing for quiet and reduced motion, an opacity breath for warm, and a slow turn for playful. The skin plays and pauses the Web Animation as the badge enters and leaves the screen.
4.5:1 on its fill in every palette and themecontrastThe chip's text is the raised surface on the tone (or on-accent on accent). Every tone is already 4.5:1 against the surfaces, so the pair holds, and the tests check it for every palette and theme.

Accessibility

  • The badge is inline text. Nothing about it is focusable or interactive; if a status needs an action, put a button beside it.
  • The shape and the kolam are aria-hidden or content-free. The words are the only thing read.
  • Busy badges must say what is happening in words. Motion is decoration: none in quiet, none under reduced motion, paused off screen.
  • Every tone's text is 4.5:1 or more on every surface in warm, and on the tone's own fill in playful (tested for Susegad and Casa, light and dark).

Credit

The kolam flower is a small four-petal pulli kolam, the dot-grid form drawn at thresholds across South India. Tier: shared practice with local forms, used here as a small ornament only.

<sg-badge> is a word or two of status: Paid, Draft, Overdue, Saving. The text is the meaning; a shape per tone backs it up; colour comes last.

Use

<link rel="stylesheet" href="susegad/components/badge/badge.css">
<script type="module" src="susegad/components/badge/badge.js"></script>

<p>Your booking is <sg-badge tone="success">Confirmed</sg-badge>.</p>
<sg-badge tone="info" busy>Saving</sg-badge>

A server can swap the words (htmx hx-swap="innerHTML") or the tone; the badge re-fits its outline and re-detects the script.

Attributes

AttributeValuesDefault
toneneutral, accent, success, warning, danger, infoneutral
busyboolean: the thing is still happeningabsent
seedany string, for the warm outlinethe text
registerquiet, warm, playfulinherited
ToneShapeUse it for
neutralringarchived, counts, facts
accentdiamondnew, featured, direct
successtickpaid, confirmed, done
warningtriangle with a bardue soon, peak season, needs a look
dangercrossfailed, overdue, declined
infocircled idraft, returning guest, checking

Registers

LookWhen busy
quiettext colour, the tone's shape, a hairline rulenothing moves; the words say it
warmthe tone's ink, a hand-inked outline drawn twicethe shape breathes slowly
playfula chip of the tone, words in the page colour, a kolam flower on the cornerthe flower turns

Reduced motion keeps every register still. Busy motion pauses when the badge is off screen.

Accessibility

How this component meets WCAG 2.2 level A and AA, criterion by criterion, how each was checked, and what your page still owns.

  • Meets 8
  • Meets with author's part 3
CriterionStatusHow it was checked
1.1.1 Non-text contentMeetsThe tone shape is a CSS mask on ::before with no content, and the warm outline and playful flower are aria-hidden SVG (packages/components/badge/badge.css, packages/components/badge/skins/warm.js, packages/components/badge/skins/playful.js), so assistive technology reads only the words.
1.3.1 Info and relationshipsMeetsThe badge is inline text. The status is its words, so there is nothing for markup to add (packages/components/badge/badge.js sets no role). Where the badge sits in a table or list is the author's markup.
1.4.1 Use of colorMeetsThe words carry the status and every tone has its own shape: ring, diamond, tick, triangle, cross, circled i. packages/components/badge/badge.test.js: "every tone has its own shape, so colour never carries the meaning alone".
1.4.3 Contrast (minimum)Meetspackages/components/badge/badge.test.js: "AA: <palette> <theme>: warm badge ink and the playful chip read at 4.5:1" for every tone on three surfaces, every palette, light and dark. Quiet text is --sg-text, tested in packages/tokens/tokens.test.js. axe color-contrast is clean in the run cited under 4.1.2.
1.4.4 Resize textMeets with author's partManual test, 2026-10-06: the demo with the root font size at 200 percent in three registers, no sideways scroll and no clipped text (throwaway Playwright script). The badge does not wrap (white-space: nowrap in packages/components/badge/badge.css), so keep the words to a word or two.
1.4.10 ReflowMeets with author's partManual test at 320 CSS px, three registers, 2026-10-06: the demo does not scroll sideways and no element passes the viewport. Because a badge never wraps, a long phrase in a narrow column would overflow it: that is the author's to keep short.
1.4.11 Non-text contrastMeetsThe tone shape and the warm outline are drawn in the tone's ink, tested at 4.5:1 on every surface for every palette and theme (packages/components/badge/badge.test.js, warm ink and playful chip rows); the quiet hairline is --sg-rule-strong, tested 3:1 or more in packages/tokens/tokens.test.js. The shape repeats what the words say, so it is not needed to understand the badge.
1.4.12 Text spacingMeetsManual test, 2026-10-06: the WCAG text-spacing values (line height 1.5, letter 0.12em, word 0.16em) injected on the demo in three registers, no clipped or overlapping text (throwaway Playwright script). Devanagari and Kannada badges get more line height in packages/components/badge/badge.css. No check in the repository asserts text spacing yet.
2.2.2 Pause, stop, hideMeets with author's partOnly a busy badge moves: a slow fade in warm and a turning flower in playful, which stop under prefers-reduced-motion, in quiet, and while off screen (packages/components/badge/badge.test.js: "busy: still in quiet and under reduced motion, breathes in warm, turns in playful"). There is no on-page pause control, so a page that shows a busy badge for more than five seconds in warm or playful owns offering the quiet register or a motion switch.
2.3.1 Three flashes or below thresholdMeetsThe busy motion is a fade between full and 40 percent opacity over 1.4 s, or a turn every 2.4 s, on a shape about 0.85em across: under one change a second and far below the flash area (busyMotion in packages/components/badge/badge.core.js).
4.1.2 Name, role, valueMeetsA badge has no role and no state of its own: its name is its text. tools/axe.mjs --url /packages/components/badge/demo.html (WCAG 2.2 AA, three registers, light and dark, desktop): 0 violation(s) across 6 run(s), 2026-10-07. No check file beside the component runs axe on it.

The page author owns:

  • The words, in the language of the page, and lang on a badge in another language (3.1.2).
  • Keeping the words short, since a badge never wraps (1.4.4, 1.4.10).
  • A busy badge that says in words what is happening ("Checking payment"), and a way to stop its motion, such as offering the quiet register (2.2.2).
  • An action for a status: the badge is never focusable, so put a button next to it.
  • The colours the page sets behind the badge, if it overrides the tokens.

How it behaves

  • Inline text, never focusable. If a status needs an action, put a button next to it.
  • Do not rely on the tone: "Failed" in a red badge still says "Failed".
  • Busy badges must say in words what is happening ("Checking payment", not only a turning flower).
  • Contrast: warm text is 4.5:1 or more on every surface; the playful chip's text is 4.5:1 or more on its own fill, in every palette and theme (tested).
  • Devanagari and Kannada badges get more line height, so matras are not clipped.

All 57 tables, and how the library tests

Budget

FileBytes
badge.js + badge.core.js (behaviour)7.4 KB of 12 KB
skins/quiet.js0.2 KB
skins/warm.js2.1 KB
skins/playful.js1.3 KB

Nothing runs per frame except a busy badge's single Web Animation in warm or playful.