Skip to main content

Components and accessibility contracts (part 1 of 6)

Part of Design system, which is built from DESIGN.md in the repository, where it is edited.

What each component must do for names, roles, focus and keyboard use.

Native elements first. No tabindex above 0. Every interactive component has an accessible name and a stable data-testid, and every floating element has data-chrome. A component moved to the message catalogue (ARCHITECTURE.md, "The message catalogue") looks its name, label or text up by MessageKey instead of writing it inline; the accessible name still contains its visible label, and each outcome still gets exactly one announcement, because the catalogue only changes where the string comes from, not these contracts.

ComponentContract
IconButtonA button named for the action ("Zoom in"). Visible labels are contained in the name.
IsolateKeeps a run of text that is not catalogue copy in its own bidirectional context, as a bdi. Wrap every place name, address, geocoder or layer-feature title, scale label and number with its unit; a name takes its direction from its first strong letter (bdi is dir="auto" already, so never add dir to it), and gets lang where the language is known. figure is for ASCII figures that always read left to right, such as the signed coordinates formatLatLng writes: it sets dir="ltr" and translate="no". Without it, in right-to-left text a signed coordinate pair, a distance with its unit or a name in another script reorders around the neighbouring punctuation. Text a message substitutes into a sentence is isolated by the catalogue instead (see "Right to left" under "Tokens"), never by markup in a message, and a copied value (the pin's coordinates) stays plain text.
ControlGroupStacked icon buttons with hairline dividers. A group, not a toolbar.
SearchPillrole="search" with an ARIA 1.2 combobox (aria-expanded, aria-controls, aria-activedescendant) and a "Search" button after it. Typing never searches the geocoder (Nominatim's policy forbids autocomplete): Enter or the button submits, and the results listbox appears after a submit. When the host supplies a suggestion provider, the same listbox (named "Suggestions" until a search is submitted, then "Search results") fills as the person types, once typing pauses and at least three characters are in the box: a suggestion is an option in the same markup as a result, so it takes the same keys, the same tap and the same focus rules, and picking it goes straight to its place and fills the box with its label without suggesting again. Enter with no suggestion highlighted submits the text, Escape closes the list and the next character opens it again, and the count is announced politely ("3 suggestions", "No suggestions"). If the service fails, the list stays closed and one polite message says that suggestions are unavailable and Enter still searches. Arrow keys move through the results, Enter on a highlighted result selects it, and Enter with none highlighted submits. A submit that finds exactly one place, a geocoder result or a coordinate pair, goes to it with no list, as long as the box still has focus when the answer arrives: the host moves the map, the box shows the place's name, focus stays in the box and one polite message says "Showing Cape Town on the map." in place of the count (onPick, which returns false to decline; a host that passes none, or a person who has moved to another control by then, gets the one result as a list). Several results open the list, and none says so, as before. Enter on the name the box was filled with searches again and goes to the place again, which lets a person who has panned away return; it is one more request, which the adapter's limit of one a second allows. Editing the text hides the old results. Results never take focus. The geocoder adapter starts at most one request a second. Text that is a pair of coordinates (-26.2041, 28.0473, 26.2041° S 28.0473° E, S26.2041 E28.0473 or degrees, minutes and seconds such as 26°12'14.8"S 28°02'50.3"E) is answered on submit by the pill itself, with no request: it is one result, named in words, "Coordinates 26.20410° S, 28.04730° E" (the core coordinate formatters), so like any single result it is gone to at once, announced ("Showing Coordinates 26.20410° S, 28.04730° E on the map.": the label is in the message so a second pair is never silent) and filled into the box exactly as a geocoder result is, and reads back as the same place to about a metre. A plain pair is read latitude first. Each value must carry a mark that says it is degrees: a decimal point with digits after it, or a degree sign (or the word degrees); a bare whole number is not enough, so 12 34, E1 6, 3 4 and +27 82 go to the geocoder. A minus sign (hyphen, en dash or Unicode minus) starts a value only when no digit or dot touches it from before, so 02-123 and 12-14 are not pairs. A value out of range, a lone number such as a postcode, and anything with text left over go to the geocoder as usual. The Directions panel's place search reads coordinates the same way, but it passes no onPick: choosing a stop is the person's decision, so a single result, a coordinate pair included, stays a list of one to choose from.
SheetA labelled dialog. Non-modal at peek and half. At full it is modal, the background is inert, Tab wraps inside it (with a focus sentinel at each end for Safari, whose Tab skips links and buttons) and Escape closes it. The handle is a button that cycles detents with Enter or Space and moves with the arrow keys. On desktop it is a labelled complementary region. A host may pass a decorative brand (a mark and a name): the sheet draws it in a small row above the title, aria-hidden and with nothing to focus, so the title stays the accessible name. The bottom sheet leaves the row out at the peek detent. MapCairn passes its cairn mark and name, whose stones take the accent and whose halo takes the map halo role, so it reads on the panel surface in both themes.
MapReadoutA landmark named "Map scale" holding the scale bar (an image named with the spoken scale) and, on one surface under it, the cursor coordinates and the zoom level, such as "z 12.4". The zoom is the normalised 256 px zoom the address uses, formatted by formatZoom with one decimal at most, in tabular-nums with no new tokens, and it sits after the coordinates in the same box, so the readout stays one floating element. The drawn "z 12.4" is aria-hidden and user-select: none; visually hidden text carries "Zoom 12.4" (after a comma when the coordinates come first), so a screen reader and a copy of the text read the zoom once, as "-26.20410, 28.04730, Zoom 12.4". It is plain text, not a live region: the settled zoom is already announced after each zoom, so a change is not spoken. The zoom adds a row at rest, so the showZoom prop, when left out, follows the chrome layout: shown in the side panel layout and left out in the bottom sheet layout, which keeps the readout short on a small screen. The credits popover does not depend on that: while it shares width with the readout it rises above the whole bottom row, whatever the readout's height, so the coordinates under a hovering pointer never collide with it, and where the two share no width it stays next to its button. Pass showZoom to decide it yourself. The web host (AppReadout) passes it as a fine pointer in the side panel layout (768 px wide or more, or under 500 px tall), and the coordinates need only a fine pointer. A fine-pointer window narrower than that therefore shows the coordinates on hover but no zoom, deliberately; a phone shows neither.
AttributionA "Map credits" button with aria-expanded and aria-controls. The button is a round chip on the same translucent chrome surface as the other controls, so its glyph keeps 3:1 over a light or a dark map in both themes (e2e/credits-button-contrast.spec.ts); it overrides the IconButton recipe with its own class, which beats the recipe whatever the stylesheet order ("Overriding a primitive"). The popover is a labelled region with real links and returns focus on close. It shows by itself once the map has started, without taking focus, and collapses on the first map interaction or after five seconds (fading, unless reduced motion is on), because the OpenStreetMap attribution guidelines allow credits to collapse only after they have been shown. It opens above the bottom row, so it clears the readout beside the button (the scale bar, and the cursor coordinates while a pointer is over the map), and slides, rather than jumps, when the coordinates change the readout's height (data-settled, a transform transition with the base motion duration); where it shares no width with the readout it sits next to the button instead (data-readout-clear), or beside the end stack when the links would have to scroll there (a short landscape phone). A host with another card on the map, the first-visit tour, holds the first showing back with introHeld: the two would cover much of a small screen together, and the reference host holds it in every layout while its tour is on screen (data-intro-held says so). The wait ends when the tour is closed or skipped, on the first zoom the person makes, the first time the map moves, or after ATTRIBUTION_HOLD_MAX_MS (30 seconds from the map starting), whichever comes first, and the credits then show for the full five seconds. A person who opens them by hand while they wait has seen them. The credits button is on screen throughout. The host may add an About link (aboutLink, a path on its site or an http or https address) as the last item, set apart by a hairline and opening in the same tab, so a visitor who arrives from a shared link has a way to the product page from a button that is always on screen.