Skip to the content

Kongens Nytorv

Metro M1, M2 and M3.

M2

Sizes

M2
Mediumsize.badge · 22 px
M2
Largesize.badge-lg · 34 px

Props

NameTypeDefaultDescription
line*'m1' | 'm2' | 'm3' | 'm4' | 'a' | 'b' | 'c' | 'e' | 'f' | 'h' | 'bus' | 'regional'—The line whose colours the badge takes: a metro line (m1 to m4), an S-tog line (a to h), any bus (bus), or any regional or Øresund train (regional). Required, with no default; set on the root as data-line.
size'medium' | 'large''medium'medium is the badge in rows and lists, size.badge tall; large is the badge in a panel's header, size.badge-lg tall. Both sizes set the label in typography.badge.
children*ReactNode—The line's short name as riders know it: "M1", "A", "5C", "RE". Required: the badge never derives it from line, which holds no bus number.
line (required)'m1' | 'm2' | 'm3' | 'm4' | 'a' | 'b' | 'c' | 'e' | 'f' | 'h' | 'bus' | 'regional', default —
The line whose colours the badge takes: a metro line (m1 to m4), an S-tog line (a to h), any bus (bus), or any regional or Øresund train (regional). Required, with no default; set on the root as data-line.
size'medium' | 'large', default 'medium'
medium is the badge in rows and lists, size.badge tall; large is the badge in a panel's header, size.badge-lg tall. Both sizes set the label in typography.badge.
children (required)ReactNode, default —
The line's short name as riders know it: "M1", "A", "5C", "RE". Required: the badge never derives it from line, which holds no bus number.

Use it

import { LineBadge } from '@mylder/perron'

Ask your agent

search_docs({ query: "LineBadge" })

Keyboard and ARIA

No keys: the badge is not focusable and does nothing when pressed (CR-2).

ElementRoleAccessible name fromStates announced
rootnone: a <span>, read as its textIts text, the caller's childrennone

The label alone is what a screen reader hears, with no owned word for the mode ("Bus", "Metro") and no aria-label: the label is the line's name as riders say it, the colour only repeats it, and the row the badge sits in names the rest. A <span> without a role can't carry aria-label reliably either.

What axe won't catch, from the contract, each with how this component meets it:

  • Everything the eye is told, the ear is told, for every shape each prop accepts: the colour names the line, and the label, which a screen reader reads, names it too, for every line value; children is required.
  • Every landmark and named region has an accessible name: none here; the badge is inline text.
  • Every default label can be overridden: no owned strings, so no *Label props.
  • Every shape the type accepts renders, in every variant: children renders as a string, an element and a list alike, inside the fixed-height box, on one line.
  • A hidden copy kept for animation is aria-hidden, and a collapsed region is inert: none here; the badge has no motion.
  • Native semantics first: a plain <span>, no ARIA.
  • Focus moves in reading order and returns on close: never focused; it has no tab stop.
  • Every target is at least size.target-min square: no target; a pressable line is the caller's button or link around the badge, which meets the minimum itself.
  • Loops stop when the system asks for less motion: none here; the badge has no motion.

Owned strings

No owned strings: the label is the caller's children, and the badge announces nothing else.

Do and don't

For a caller using the component, with the reason. Each row is a rule: a must row's Don't is never right, a should row's needs a reason, and Checked by says what catches the Don't in a caller's code.

RuleLevelDoDon'tChecked by
DD-1mustName the line in words near the badge, such as "M1 towards Vanløse", because five official pairs (M1, M4, A, B, C) miss 4.5:1 and stay soRely on the badge's label alone where the line matters, such as the only mention of a line in a disruptionreview
DD-2shouldPass the name riders know as children: "5C", "A", "RE"Pass a sentence or a mode word ("Bus 5C"); the colour already says the mode, and the badge is sized for a short namereview
DD-3mustUse a line colour as a fill only in a LineBadge, and as a dot, ring, rail or swatch elsewhere, as Semantic colours saysFill another shape, such as a chip or a panel header, with a line colourreview
DD-4mustWrap the badge in a Perron button or link when the rider can open the lineAdd onClick or tabIndex to the badge; it has no focus ring, role or target sizereview
DD-5shouldKeep brand buttons out of rows of line badgesPut a brand button beside bus badges, where its yellow fill and ink label read as one more busreview
DD-6shouldChoose large only for the one badge that heads a panelMix sizes in one row or listreview