Skip to
Keyboard shortcuts

Use the up and down arrow keys to move between items. Press Alt+Shift+K to open this list again.

Alpha version out now. The API may still change.

Map

Places on a map and the same places as a list, with the keyboard and a button for every gesture. You choose where the map pictures come from. Nothing is requested from anyone until a map with a provider is on the page.

Package
@kvirn-ui/map
Pattern
None: there is no APG pattern for a map. The markers use the Toolbar’s arrow keys.
Testing
Not yet verified. Automated 3 of 5, Core 0 of 2, Release 0 of 3

When to use it#

  • Use it when the question is where a place is: the nearest preschool, the recycling stations in a district, the polling station for an address. The same places are always in a list, so nobody has to use the map to reach one.
  • Not for a single address: write it as text, with a link to a map service. Not for a long list with no question about where: use a list or a Table.
  • Tiles (the map pictures) are your choice. The library names no tile server, and it has no default. A visitor’s browser asks your tile host for each picture, so the host sees the visitor’s IP address: name it in your privacy notice. A provider is the code that draws the map, such as MapLibre. Nothing is requested until a Map.Root with a provider is on the page.
  • The map has no address search of its own. A visitor finds a place by the markers, the list and the layers. To let a visitor search for an address, put an AddressSearch beside the map.
  • It is its own package, @kvirn-ui/map. Its styles are an opt-in import, @kvirn-ui/theme/map.css, after theme.css, so a site without maps does not pay for them. MapLibre is an optional peer. The install lines are in the API reference.

Example#

The examples on this page load their map from geo.kvirn.com, Kvirn’s own map service, hosted in the EU and setting no cookies. Your browser asks it for the map as soon as a map is shown, so it sees your IP address and the area you view. Move the map with the mouse, the arrow keys or the buttons, press a marker or a name in the list, and watch the list follow the view.

Use cases#

Finding a preschool near you

A parent looks for a preschool close to home. The list gives each name and address, and your own line under it, such as opening hours. A popup opens with a picture, the address and a few words, anchored to the place on the map.

Props in this example:

Warning: Don't forget

Describe every picture in image.alt, or use an empty alt when it only decorates. Without it a screen reader user gets no idea what the picture shows (1.1.1 Non-text Content).

Showing only the kinds of place you want

A resident wants the hazardous waste depot, not the recycling stations. Layers let them show or hide each kind. Each layer’s checkbox says how many places it holds. Hiding a layer takes its markers and rows away and announces the new count, and focus stays on the checkbox. The card starts open; set defaultOpen={false} for a long list of layers, so it does not cover the map.

Props in this example:

Warning: Don't forget

Every layer has a name in the checkbox and in the list, so colour is never the only difference (1.4.1 Use of Color). If you give layers their own marker pictures, give each an icon or a shape too, not only another colour.

Many places close together

On election day the map shows every polling station in the municipality. Where several are close, the map groups them in one button with the number on it. Pressing it opens a popup that lists them, and choosing one opens its details, so no place hides behind another. Zoom in with the + button and the groups split.

A list of your own

Your service already has a list with more than names: a distance, a filter, a link to book. Build it from useMapState and point Map.Skip at its heading. Opening a place from your list works like the library’s: focus moves to the title, and closing returns it to your button.

Props in this example:

Warning: Don't forget

Without Map.List you must give people another way to reach and open every place. The library cannot check this (1.1.1 Non-text Content, 2.1.1 Keyboard, 2.5.7 Dragging Movements).

Letting people choose the map type

Some residents read a street map more easily than a plain one, or the other way round. Give the map two or more map types and add Map.BaseMapSwitch: a button that opens a small choice with a preview of each. The choice is announced, and the places, the list and the keyboard work the same on every map type. With fewer than two map types the switch renders nothing. See Map.BaseMapSwitch in the API.

Warning: Don't forget

Give each map type a clear label and its own attribution. The label names the choice for a screen reader, and the attribution must change with the map type (1.1.1 Non-text Content).

Information: Implement like this

Add your own map types, such as an aerial photo, from a tile host you have an agreement with. This example does not load one.

import { maplibre, rasterStyle } from '@kvirn-ui/map/maplibre'
import { kvirnBaseMap } from '@kvirn-ui/map/kvirn'

export const provider = maplibre({
  baseMaps: [
    kvirnBaseMap({ url: 'https://geo.kvirn.com' }),
    {
      id: 'aerial',
      label: 'Aerial photo',
      attribution: '© Example municipality',
      style: rasterStyle({
        tiles: ['https://tiles.example.org/aerial/{z}/{x}/{y}.jpg'],
        attribution: '© Example municipality',
      }),
    },
  ],
})

Make it your own

A municipality shows its places for children and families: playgrounds, libraries and swimming halls. A resident sees a different shape and colour for each kind, the library names on the map, a popup with opening hours and a link for directions, and switches that say how many places each kind holds. You write the markup; names, focus, announcements and keyboard come from the parts, so they keep working.

Props in this example:

Warning: Don't forget

A custom popup must keep titleProps on its title and a Close button, so focus and the dialog’s name still work. Wrap a whole template, in the details or the cluster popup, in kv-map-details-content to get the popup’s padding. A custom switch must name each layer and call setLayerHidden. A custom marker is decoration: its name comes from label, and the shape, not only the colour, tells the layers apart (1.4.1 Use of Color).

Accessibility#

What it does for you#

  • APG pattern: none. There is no APG map pattern. The keys follow the keyboard interface practice, and the markers follow the Toolbar arrow model.
  • Deviations: the markers in view are one Tab stop and the arrow keys move between them, where a Tab stop per marker is unusable with many places. Arrows on the viewport pan and + / - zoom, while it has focus. Approved by the maintainer.
  • Native elements used: <div role="region"> (Viewport), <div role="group"> (Markers, Controls), <button> (marker, cluster, controls, list row trigger, place in a cluster, Close), <a> (skip link), radio group (BaseMapSwitch), <fieldset> and checkboxes (Layers), a heading (h2 by default, headingLevel sets it) and <ul> (List), <dialog open> (Details and ClusterPopup, non-modal) with an <img>, a heading, <p> for the body and address, <p> (Attribution).

A Map shows places on a camera over a base map, with the same places as a list. It is one focusable region you can pan and zoom from the keyboard, with a set of markers that is a single Tab stop, buttons for every gesture, and a list that is the screen reader user's equivalent of the map.

PartElement / roleARIA / stateNotes
Map.Root<div class="kv-map">noneOwns the camera, the selected place and the base map. label is the viewport's name
Map.Skip<a> skip linknonemap.skipToList. Goes to the details title while a place is open, else to Map.List, else to href; nothing is rendered with none (2.4.1)
Map.Viewport<div role="region" tabindex="0">aria-label the consumer's label, aria-roledescription map.roleDescription, aria-describedby the summary and the hintThe engine's canvas inside is aria-hidden and out of the tab order. data-status is loading, ready or failed
Map.Markers<div role="group">aria-label map.markersLabelOne Tab stop: tabindex="0" on the selected marker, else the first, -1 on the others
Marker<button>named by the place's name, aria-expanded, aria-controls the detailsOpens the details. data-highlighted while its list row is hovered
Map.Controls<div role="group">aria-label map.controlsLabelIcon-only buttons named map.zoomIn, map.zoomOut, map.panNorth and so on, a text button map.reset last (the zoom pair, the pan disc and Whole map are one visual stack in that order)
Map.Attribution<p>aria-label map.attributionLabelThe consumer's text and links. Native links
Map.BaseMapSwitch<div> with a <button> and a popover (role="dialog") holding a radio groupbutton: name map.baseMapLabel, aria-expanded, aria-controls; popover: aria-label map.baseMapLabel; legend map.baseMapLabelThe button shows the current map. Renders nothing with fewer than two base maps. Native radios, as on the RadioGroup and Popover pages. The render function form replaces the button and the popover
Cluster<button class="kv-map-cluster">named map.clusterLabel / map.clusterLayerLabel, aria-haspopup="dialog", aria-expanded, aria-controls the popupShares the one Tab stop with the markers. The visible count is part of the name (2.5.3). When its layer has an icon, the icon is drawn before the count by default, aria-hidden and not part of the name (1.4.1). Moves the cluster low in the view without zooming, then opens the popup
Map.Layers<fieldset role="none"> holding a <button> and a <fieldset aria-label>; with collapsible={false} a <fieldset> with <legend>button map.layersLegend (plus map.layersHiddenValue while collapsed and a layer is hidden), aria-expanded, aria-controls; inner fieldset aria-label map.layersLegend; one checkbox per layer named with its count (map.layerCountValue: "Hotels 100")Open by default (defaultOpen, or open and onOpenChange). Collapsed, the panel is hidden: its checkboxes are not exposed and not in the Tab order. The fieldset is only the card, so a collapsed card has one name (the button's) and an open one names the group once; disabled still reaches every checkbox. The layer's description is the checkbox's help text; the swatch is aria-hidden. Renders nothing without layers. Native checkboxes, as on the Checkbox page
Map.ClusterPopup<dialog open aria-labelledby> with a headingthe heading is map.clusterTitle / map.clusterLayerTitle; Close is named map.clusterClose with the titleSame frame as Details. A list of buttons, one per place, with the address under it. Only one of the two popups is open at a time. No focus trap
Map.List<h2 tabindex="-1"> (headingLevel sets the level) and <ul role="list">each row's trigger is a <button aria-expanded aria-controls>The heading states the count (map.placesInView or map.placesAll). Empty: map.listEmpty
Map.Details<dialog open aria-labelledby> with a headingClose is named map.detailsClose with the titleHeading tabindex="-1" takes focus on open. A non-modal popup, at every width: above the marker, below when there is no room above, scrolling inside the room it has. It never covers the marker and is never a panel under the map. No focus trap (Tab leaves it). Image: alt is the consumer's, '' when decorative; image, body and address are optional

These are the rules the map follows (the Keyboard table names the test for each key; not every rule below has a test):

  • Equivalent. Every place in the data is in the list, and the viewport's description states the count (1.1.1, 1.3.1).
  • Names. The viewport's name is the consumer's label and its role description is map.roleDescription.
  • Layers and clusters. The layers card collapses behind a button (open by default, so a long list does not cover the map); collapsed it shows how many layers are hidden. Hiding a layer removes its markers, clusters and list rows, closes a popup of its place or cluster, leaves focus on the checkbox, and announces map.placesInView (or map.placesAll). A cluster holds one layer's places, changes on whole zoom steps only, and the selected place is never in one. An open cluster that no longer exists closes, and focus follows the chain below.
  • Focus. Opening details or a cluster popup moves focus to its heading. Closing returns it to the opener (the marker, the cluster or the list row), else the list heading. Never body (2.4.3).
  • Keys are taken only while the viewport has focus and never with Control, Command or Alt, so browser zoom keeps working (1.4.4, 2.1.4).
  • Pointer. Drag pans, one finger scrolls the page on touch and two fingers pan, the wheel scrolls the page and zooms with Control or Command. A hint (map.gestureTouch, map.gestureWheel) shows until the next interaction. Every gesture has a button (2.5.1, 2.5.7). Buttons are at least 24 by 24 CSS px (2.5.8).
  • Failure. When tiles fail, map.tilesFailedTitle and map.tilesFailedBody show in the viewport and the list still works (3.3.1). Test: map.test.tsx › when the tiles fail the viewport says so and the list still opens a place.
  • WCAG SCs: listed with their proof under WCAG SCs covered.

What you need to do#

  • Keep the list. Render Map.List, or your own list built with useMapState and a Map.Skip with href. Without a list, people who cannot use the map have no way to reach a place (1.1.1 Non-text Content, 2.1.1 Keyboard, 2.5.7 Dragging Movements). The library cannot check this.
  • Name the map. label is required. Write it in the page's language.
  • Describe place pictures. image.alt is required: describe the picture, or use alt="" when it only decorates (1.1.1).
  • Never tell layers apart by colour alone. Marker content is decoration and the name comes from label and clusterLabel. Give each layer an icon or a shape (1.4.1 Use of Color; set icon on the layer and its clusters draw it before the count; tested in map.test.tsx › a cluster of a layer with an icon draws it before the count, hidden from the name), and keep each shape at 3:1 contrast against the map (1.4.11 Non-text Contrast). Keep the marker and cluster buttons at least 24 by 24 CSS px (2.5.8 Target Size (Minimum)).
  • Put the chrome where the map expects it. Map.Layers, Map.BaseMapSwitch, Map.Controls and Map.Attribution go inside Map.Viewport. Wrap any floating part of your own in Map.Overlay, so a focused marker is moved out from under it (2.4.11 Focus Not Obscured (Minimum)).
  • Give a replaced map type switch a visible label when you pass a function to Map.BaseMapSwitch (3.3.2 Labels or Instructions).
  • Prefer vector tiles. Raster tiles are images of text that do not follow the visitor's text size (1.4.4 Resize Text, 1.4.5 Images of Text).
  • Choose the tile host and say so. The library has no default tile source. The visitor's IP address reaches the host you choose when the first tile is requested, so name that host in your privacy notice. Nothing is requested until a Map.Root with a provider mounts.
  • Show the attribution that your tile or data licence asks for with Map.Attribution. Leaving it out is a licence problem, not an accessibility one.
  • Keep places, layers and the provider stable between renders (a constant or useMemo).
  • Install the engine's CSS yourself (maplibre-gl/dist/maplibre-gl.css), and under Vite pass workerUrl. The package ships neither.
  • Keep clustering on for a large source. With cluster={false}, every place in view is a button on the page.

Warning: Don't forget

Keep a list of every place, and name the map with label. Without a list, someone who cannot use the map cannot reach a place (2.1.1 Keyboard).

Visual and modes#

  • Focus. A keyboard-focused marker, control and list row show a ring in the focus colour with a canvas gap, so it reads on any tile. A focused marker under an overlay is panned clear of it (2.4.7, 2.4.11).
  • Over imagery. Anything drawn on the map has a canvas edge, then a 1px text edge (the halo), one of them light and one dark in every theme, so its edge is at least 3:1 on any tile (1.4.11). The pairs are the theme's, checked by theme:check; no new pair.
  • Not colour alone. The selected marker differs by shape as well as colour, a checked map type by a check, and a layer by its name and swatch (1.4.1).
  • Target size. Controls, markers, the Layers and Map type buttons and list rows are 44px (32px compact) with a mark of at least 24px (2.5.8).
  • Reflow. Below 40rem the chrome is a grid around the map: Layers, Map type, the map, Controls as a wrapping row, then Attribution. Nothing clips at 320px or at 400% zoom (1.4.10). The Controls stay the alternative to a two-finger pan (2.5.7).
  • Forced colours. The viewport, hint, status, attribution and control surfaces use Canvas with a CanvasText edge, markers use system colours with a different shape for the selected one, a checked tile is Highlight with HighlightText plus its check, and disabled is GrayText.
  • Reduced motion. Colour, background, border, shadow and opacity change only under prefers-reduced-motion: no-preference. Under reduced motion the camera jumps instead of easing. Nothing moves, scales or runs on exit.
  • Right-to-left. The chrome uses logical properties. The map and the pan buttons are physical, so the viewport arrows never flip, and the marker arrows flip (map.test.tsx › the arrows pan the same way in RTL, map.test.tsx › the arrows move between the markers in RTL).
  • Raster tiles. A raster tile's labels are an image of text that does not follow the text size (1.4.4 Resize Text, 1.4.5 Images of Text, both AA). The tile source is yours; vector tiles are advised.

Focus management#

  • Initial focus: none. The map never moves focus on its own: a pan, a zoom, a changed map type and a result shown on the map leave focus where the user put it (3.2.2).
  • Opening details: focus moves to the details heading (tabindex="-1"), so a screen reader reads the place.
  • Closing details: focus returns to the marker or the list row that opened them, else the list heading. Never body.
  • Never obscured by: floating chrome never covers a keyboard-focused marker or cluster (2.4.11). Map.Controls, Map.Attribution and the consumer's Map.Overlay register their element, and focus pans the map the smallest distance (least movement; centred when nothing fits) that clears the marker, padded by the focus ring and a gap, of every overlay and of the viewport's edge. The popup is not an overlay: it is anchored to the marker, and its room is the map's own row (the engine element), so below 40rem it never covers the controls (map.test.tsx › the details popup stays inside the map row when the viewport has more rows below it). Nothing is sticky.

WCAG success criteria#

  • 1.1.1 Non-text Content (A), 1.3.1 Info and Relationships (A), 1.3.2 Meaningful Sequence (A): the list holds every place and the viewport states the count; the canvas is aria-hidden (the Equivalent and Names rules, and map.test.tsx › a marker with no children shows a decorative pin and keeps the place name).
  • 1.4.1 Use of Color (A), 1.4.11 Non-text Contrast (AA): shapes and the halo, with the theme's pairs checked by theme:check. No unit test asserts the shapes.
  • 1.4.4 Resize Text (AA), 1.4.10 Reflow (AA): the reflow sweep project renders the stories at 320px, which is 400% zoom. map is in sweepComponents (vite.config.ts), but the map stories have not been swept yet, so this stays pending.
  • 1.4.13 Content on Hover or Focus (AA): nothing opens on hover or focus alone; a popup opens on Enter or Space and closes with Escape (map.test.tsx › Escape closes the details and returns focus).
  • 2.1.1 Keyboard (A), 2.1.2 No Keyboard Trap (A), 2.4.3 Focus Order (A): every row of the Keyboard table names a test.
  • 2.4.7 Focus Visible (AA): the focus-ring pair is checked by theme:check, and the forced-colors sweep runs the stories once the map stories are swept (pending). No keyboard test asserts the ring.
  • 2.1.4 Character Key Shortcuts (A): the keys are taken only while the viewport has focus and never with Control, Command or Alt (the viewport rows of the Keyboard table).
  • 2.4.1 Bypass Blocks (A): the skip link (map.test.tsx › Tab reaches the skip link and the viewport).
  • 2.4.11 Focus Not Obscured (Minimum) (AA): map.test.tsx › a marker focused by keyboard under an overlay is panned clear of it, map.test.tsx › Map.Controls count as an overlay.
  • 2.5.1 Pointer Gestures (A), 2.5.7 Dragging Movements (AA): every gesture has a button (map.test.tsx › the control buttons zoom, pan and reset).
  • 2.5.3 Label in Name (A): markers are named by the place and clusters by their count (the Names rules). 2.5.8 Target Size (Minimum) (AA): the theme sizes the targets; no test asserts it.
  • 3.2.1 On Focus (A), 3.2.2 On Input (A): the map never moves focus on its own (address-search.test.tsx › show(result) fits the bounds or centres, draws the pin, keeps focus and announces addressShown once settled).
  • 3.3.1 Error Identification (A): the tile failure message shows in the viewport, and the list still works (map.test.tsx › when the tiles fail the viewport says so and the list still opens a place).
  • 4.1.2 Name, Role, Value (A), 4.1.3 Status Messages (AA): the roles and names in the table above, and the announcements above.

Keyboard#

Focus
roving tabindex
Selection follows focus
no (Enter or Space opens the details)
Arrows wrap
yes (the markers)
Shortcuts
none
KeyWhereWhat happens
Tabbefore the mapMoves focus to the skip link, then the viewport. The viewport is one stop
Test: map.test.tsx › Tab reaches the skip link and the viewport
Shift+Tabon the viewportMoves focus back to the skip link, then the previous focusable element
Test: map.test.tsx › Shift+Tab leaves the viewport backwards
ArrowUp / ArrowDownon the viewportPans the map north or south by a quarter of the viewport's shorter side
Test: map.test.tsx › the arrows pan the map
ArrowLeft / ArrowRighton the viewportPans the map west or east. Spatial, so never flipped in RTL
Test: map.test.tsx › the arrows pan the same way in RTL
+ / =on the viewportZooms in. With Control or Command it is the browser's
Test: map.test.tsx › plus zooms in
-on the viewportZooms out. With Control or Command it is the browser's
Test: map.test.tsx › minus zooms out
Escapeon the viewportHides the keyboard hint; otherwise the page's
Test: map.test.tsx › Escape hides the keyboard hint
Tabafter the viewportEnters the markers at the selected one, else the first in list order. Layers and Map type come first when you render them before the markers. The next Tab leaves the markers
Test: map.test.tsx › the markers are one Tab stop
ArrowRight / ArrowDownon a markerMoves to the next marker in list order, and wraps. ArrowRight flips to ArrowLeft in RTL
Test: map.test.tsx › the arrows move between the markers
ArrowLeft / ArrowUpon a markerMoves to the previous marker, and wraps. ArrowLeft flips to ArrowRight in RTL
Test: map.test.tsx › the arrows move between the markers in RTL
Home / Endon a markerMoves to the first or the last marker
Test: map.test.tsx › Home and End move to the first and last marker
Tab / ArrowUp / ArrowDown / ArrowLeft / ArrowRightonto a marker or clusterKeyboard focus only: if the marker is under a Map.Overlay, Map.Controls or Map.Attribution, or outside the viewport, the map pans the least that clears it, with the motion preference. Not announced; a pointer press never pans
Test: map.test.tsx › a marker focused by keyboard under an overlay is panned clear of it
Enter / Spaceon a markerOpens its details. Focus moves to the details heading
Test: map.test.tsx › Enter and Space open the details
Enter / Spaceon a control buttonZooms, pans or resets the map. The change is announced
Test: map.test.tsx › the control buttons zoom, pan and reset
Tab / Shift+Tabacross the controlsMoves through zoom in, zoom out, the four pan buttons (north, west, east, south) and Whole map, in that order: the visual order. Layers and Map type come before them when you render them first
Test: map.test.tsx › Tab moves through zoom in, zoom out, the four pan buttons and Whole map
Enter / Spaceon a list row's triggerOpens that place's details and moves focus to the details heading
Test: map.test.tsx › a list row opens the details
Tab / Shift+Tabin a virtualized list (over 50 rows)Enters at the last focused or opened row, else the first rendered one; the next Tab or Shift+Tab leaves the list. Up to 50 rows, every row's trigger is a stop
Test: map.test.tsx › a virtualized list is one Tab stop
ArrowDown / ArrowUpon a row in a virtualized list or cluster popupMoves to the next or previous row, rendering and focusing it. Does not wrap, is not flipped in RTL
Test: map.test.tsx › the arrows move between virtualized rows, map.test.tsx › the arrows move between virtualized rows in the cluster popup
Home / Endon a row in a virtualized listMoves to the first or the last row
Test: map.test.tsx › Home and End move to the first and last virtualized row, map.test.tsx › Home and End move to the first and last virtualized row in the cluster popup
PageUp / PageDownon a row in a virtualized listMoves by the number of rows that fit the scroll element
Test: map.test.tsx › PageUp and PageDown move by a page of rows, map.test.tsx › PageUp and PageDown move by a page of rows in the cluster popup
Escapefocus inside the detailsCloses the details and returns focus to the opener, else the list heading. Never body
Test: map.test.tsx › Escape closes the details and returns focus, map.test.tsx › Escape closes the details and returns focus to the list heading when the opener is gone
Enter / Spaceon Close in the detailsCloses the details and returns focus to the opener
Test: map.test.tsx › Close closes the details and returns focus
Tabafter the viewportClusters and markers are in the same single stop: enters at the selected marker, else the first in view
Test: map.test.tsx › clusters and markers share the one Tab stop
Enter / Spaceon a clusterOpens the cluster popup and moves focus to its heading. aria-expanded is true
Test: map.test.tsx › Enter and Space open the cluster popup
Tab / Shift+Tabin the cluster popupMoves through the place buttons and Close, then leaves the popup (no trap)
Test: map.test.tsx › Tab moves through the cluster popup
Enter / Spaceon a place in a clusterCloses the popup and opens that place's details. Focus goes to the details heading
Test: map.test.tsx › a place in a cluster opens its details
Escapefocus in the cluster popupCloses it and returns focus to the cluster, else the list heading
Test: map.test.tsx › Escape closes the cluster popup and returns focus, map.test.tsx › Escape closes the cluster popup and returns focus to the list heading when the cluster is gone
Enter / Spaceon Close in the cluster popupCloses it and returns focus to the cluster
Test: map.test.tsx › Close closes the cluster popup and returns focus
Enter / Spaceon the layers buttonCollapses or opens the layers card; focus stays on the button, aria-expanded follows. Collapsed, the checkboxes leave the Tab order
Test: map.test.tsx › Enter and Space on the layers button collapse and open the layers
Tab / Shift+Tabpast the collapsed layers buttonThe checkboxes are hidden, so Tab skips them (defaultOpen={false})
Test: map.test.tsx › defaultOpen false starts with the layer checkboxes out of the Tab order and not exposed
Enter / Spaceon the layers button, with open setReports the new state in onOpenChange; the card follows open
Test: map.test.tsx › open and onOpenChange control the layers card
Spaceon a layer checkbox (a layer row)Toggles the layer: its markers, clusters and list rows go or return, map.placesInView is announced, focus stays
Test: map.test.tsx › a layer checkbox toggles with Space
Enter / Spaceon the Map type buttonOpens the popover without moving focus; the radios follow the button in the Tab order
Test: map.test.tsx › Map type opens from its button, an arrow key changes the map, Escape returns focus
ArrowUp / ArrowDown / ArrowLeft / ArrowRighton a map type radioNative: moves the choice and changes the map type, which is announced
Test: map.test.tsx › Map type opens from its button, an arrow key changes the map, Escape returns focus
Escapefocus in the Map type popoverCloses it and returns focus to the Map type button
Test: map.test.tsx › Map type opens from its button, an arrow key changes the map, Escape returns focus

The map takes no other key. Keys on the viewport are read only while the viewport itself has focus, so a button or a link inside keeps its own keys. Control, Command and Alt combinations are never taken.

Information: Did you know?

Only the map itself takes keys, and only while it has focus. Combinations with Control, Command or Alt are never taken, so the browser’s own zoom keeps working (2.1.4 Character Key Shortcuts).

Announcements#

Map tells screen reader users about these changes without moving focus. Each message waits until the screen reader is quiet (polite) or interrupts it (assertive).

WhenWhat it saysMessage keyPoliteness
The view settles (about 500 ms later) after a key, a button or Whole map moved it, and the count of places changed12 places in the map view.map.placesInView map.placesAllPolite
A layer is shown or hidden12 places in the map view.map.placesInView map.placesAllPolite
A zoom button or key is used at the limitYou can't zoom in any further.map.zoomLimitIn map.zoomLimitOutPolite
The tile source fails (once per failure)The map can't be shown right nowmap.tilesFailedTitlePolite
The visitor changes the map typeMap type: Satellite.map.baseMapChangedPolite
The index of a large source starts to build (once)Loading the placesmap.indexingPolite

The text in all five languages

Change the text#

For your whole app, pass messages to KvirnProvider. For one Map, pass its messages prop.

<KvirnProvider messages={{ map: { placesInView: '12 places in the map view.' } }}>

Warning: Don't forget

Announcements need a KvirnProvider around your app, outside any <form>, or an Announcer of your own. Without one nothing is announced, and a development warning says so.

API reference#

Install the package. Install MapLibre only if you use its adapter. Import the styles once, after the theme.

pnpm add @kvirn-ui/map
pnpm add maplibre-gl
import '@kvirn-ui/theme/theme.css'
import '@kvirn-ui/theme/map.css'
import 'maplibre-gl/dist/maplibre-gl.css'

Information: Implement like this

Create the provider once, outside your component, so the instance stays the same between renders. Use a tile host you have an agreement with, and say so in your privacy notice.

import { maplibre, rasterStyle } from '@kvirn-ui/map/maplibre'

// Create it once, outside your component. The tile address is yours.
export const provider = maplibre({
  style: rasterStyle({
    tiles: ['https://tiles.example.org/{z}/{x}/{y}.png'],
    attribution: '© Example municipality',
  }),
})
import { Map, createMemoryProvider, useMap, useMapState } from '@kvirn-ui/map'
import { maplibre, rasterStyle } from '@kvirn-ui/map/maplibre'
import { createMapWorker } from '@kvirn-ui/map/worker'

Map.Root

Renders <div class="kv-map">. It owns the camera, the open place and the map type, and it takes every attribute of a <div>. It is a container, so the layout changes at 40rem of the map’s own width, not the page’s. Put Map.Skip, Map.Viewport, Map.List and the popups inside. Also exported as MapRoot.

PropTypeDefaultDescription
providerMapProviderRequiredThe engine adapter that draws the map: maplibre({ style }), createMemoryProvider() or your own. Keep the same instance between renders.
labelstringRequiredThe map’s name, which a screen reader reads for the map region. Write it in your language: “Map of preschools”.
initialView{ center: { longitude, latitude }, zoom }RequiredWhere the map starts, and where the Whole map button returns to. Changing the prop later does not move the camera.
placesreadonly MapPlace[]–The places, up to a few thousand. Keep the array the same between renders. For more, use source.
sourceMapPlaceSource–The places as columns, for tens of thousands to millions. No object exists for a place until a marker, a row or a popup needs it. Use it instead of places, and keep it the same between renders.
indexIn'main' | (() => MapIndexer)'main'“main” builds the index of a large source on the page, in slices of 8 ms. Pass createMapWorker from @kvirn-ui/map/worker to build it in a Web Worker instead.
baseMapstring–The id of the active map type. Set it to control the map type yourself and update it in onBaseMapChange. Without it the map keeps its own.
defaultBaseMapstringThe provider’s, else the firstThe map type to start on when baseMap is not set.
onBaseMapChange(id: string) => void–Called with the id when a visitor picks a map type.
layersreadonly MapLayer[]–The groups of places. A place joins one with its layer. Keep the array the same between renders.
hiddenLayersreadonly string[]–The ids of the hidden layers. Set it to control them yourself and update it in onHiddenLayersChange.
defaultHiddenLayersreadonly string[][]The layers that start hidden when hiddenLayers is not set.
onHiddenLayersChange(ids: readonly string[]) => void–Called with the ids that are now hidden when a visitor shows or hides a layer.
clusterboolean | { radius?: number }trueGroups nearby places of one layer into a cluster. The radius is 64 CSS pixels, so two clusters stay about 44 pixels (one target) apart. false turns clustering off, and a layer with cluster: false is never clustered. A cluster holds places of one layer only.
messagesPartial<KvirnMessages["map"]>–Changes the map’s texts for this map. See Strings below for every key and its English text.
Class or attributeValuesMeaning
--kv-map-block-sizea lengthThe height of the map. The default is clamp(15rem, 60vh, 40rem). Set it on the Root or on any element around it.

Map.Skip

Renders A skip link (SkipLink) to the list. Put it before the viewport.

PropTypeDefaultDescription
childrenReactNodemap.skipToListThe link text.
hrefstring–The target when you build your own list instead of Map.List, such as #my-list-heading. The link goes to the open place’s title while a place is open, else to Map.List, else to href. With none of them it renders nothing.

Map.Viewport

Renders <div role="region" tabindex="0">, named by the Root’s label and described as a map. The engine draws into it, and the markers, controls, layers and attribution are its children. It takes every attribute of a <div> except the role, the tab index and the aria-* it sets. It shows the keyboard hint, the loading and failed messages, and the gesture hint.

Class or attributeValuesMeaning
data-statusloading | ready | failedOn the viewport. Loading shows a spinner and the loading message, and failed shows that the tiles could not load. The list keeps working in both.
data-dismissedpresent or absentOn the keyboard hint, once Escape has hidden it.
data-gesturetouch | wheelOn the gesture hint: the gesture the engine ignored so that the page can scroll (one finger, or the wheel without Control or Command).

Map.Markers

Renders <div role="group"> of buttons, one per place and one per cluster in the map view. They are one Tab stop. It renders nothing while nothing is in view.

PropTypeDefaultDescription
children(place, { selected, highlighted, layer }) => ReactNode–The content of a marker: a 16 pixel icon, or a name chip in kv-map-marker-label. It is decoration inside the one button, so it is not read. The name comes from label.
label(place, layer) => stringThe place’s nameThe marker’s accessible name. Put the information in it, such as the layer: “Torget recycling station, Recycling stations”.
markerClassNamestring | ((place, layer) => string)–A class on every marker, or one per place, for example one per layer.
cluster(cluster, { opened, layer }) => ReactNodeThe number of placesThe content of a cluster’s button.
clusterLabel(cluster, layer) => stringmap.clusterLabelThe cluster’s accessible name. The default is the number of places, with the layer’s name when it has one.
clusterClassNamestring | ((cluster, layer) => string)–A class on every cluster, or one per cluster, for example one per layer.
Class or attributeValuesMeaning
data-selectedpresent or absentOn a marker whose details are open.
data-highlightedpresent or absentOn a marker while its list row is hovered, and on the row while the marker is.
aria-expandedtrue | falseOn a marker or cluster while its popup is open.

Map.Marker, Map.Cluster

Renders One native <button> each, a large touch target (44 pixels by default). A cluster has aria-haspopup="dialog". Pressing a marker opens its details, and pressing a cluster opens its popup. Use Map.Markers, which renders them.

PropTypeDefaultDescription
placeMapPlaceRequiredOn Map.Marker: the place the button stands for. Use Map.Markers, which renders the set.
clusterMapClusterRequiredOn Map.Cluster: the cluster the button stands for. Use Map.Markers, which renders the set.

Map.Controls

Renders <div role="group"> of buttons: zoom in, zoom out, four pan buttons and Whole map, in that order. Each is the single-pointer alternative to a drag or a two-finger gesture. It takes every attribute of a <div>.

Map.Overlay

Renders <div class="kv-map-overlay"> for chrome of your own that floats over the map, such as a search box or a legend. Put it inside Map.Viewport and position it with your own classes. A marker reached by keyboard is moved out from under it.

PropTypeDefaultDescription
asElementType'div'Another tag or component to render.

Map.Attribution

Renders A <p> named “Map data”, with the text and links of the active map type. Native links.

PropTypeDefaultDescription
childrenReactNode | ((baseMap) => ReactNode)The active map type’s attributionThe text and links your tile or data licence asks for. It renders nothing without text.

Map.BaseMapSwitch

Renders A button showing the current map type that opens a popover of preview tiles, one native radio each. It renders nothing with fewer than two map types. It takes every attribute of a <div>.

PropTypeDefaultDescription
icon(baseMap) => ReactNodeA plain previewA decorative preview of a map type, such as a small tile image. It is not read.
children({ baseMaps, baseMap, setBaseMap, label }) => ReactNode–Replaces the button and the tiles, for example with a native select in a Field. Give your control a visible label and render it outside Map.Viewport.

Map.Layers

Renders A card titled “Show on the map” that collapses behind a button, and one native checkbox per layer, named with its count: “Hotels 100”. While collapsed, the button says how many layers are hidden. A layer’s description is the checkbox’s help text. It renders nothing without layers.

PropTypeDefaultDescription
icon(layer) => ReactNode–A decorative swatch before the layer’s name, such as the layer’s marker icon. It is not read: the name and count are.
layerClassName(layer) => string | undefined–A class on each layer’s row, so a swatch can match its markers.
children({ layers, hiddenLayerIds, setLayerHidden, counts }) => ReactNode–Replaces the checkboxes, for example with a switch per layer.
collapsiblebooleantrueLets the visitor collapse the card behind its title. `false` keeps it always open, with no button.
defaultOpenbooleantrueWhether the layers start shown. Set `false` for a long list of layers, so the card does not cover the map.
openboolean–Controlled: whether the layers are shown. Pair it with `onOpenChange`.
onOpenChange(open: boolean) => void–Called when the visitor opens or closes the card, with the new state.

Map.List

Renders A heading that states the count, then a <ul> with a button per place in the map view. It is hidden while a place’s details are open. It is the equivalent of the map for people who do not use it.

PropTypeDefaultDescription
icon(place) => ReactNode–A decorative swatch before each row, such as the place’s marker icon.
rowClassName(place) => string | undefined–A class on each row.
children(place) => ReactNode–Extra facts under the name, such as opening hours. Keep them non-interactive: the whole row is one button. A node with the class kv-map-list-aside sits at the row’s end.
Class or attributeValuesMeaning
data-highlightedpresent or absentOn a row while its marker is hovered.
data-virtualizedpresent or absentOn the scroll element past 50 places. Only the rows in view are rendered, each with aria-setsize and aria-posinset, and the list is one Tab stop.

Map.Details

Renders <dialog open>, a non-modal popup anchored to the open place’s marker: above it, below when there is no room, and scrolling inside the room it has. It has no focus trap. Focus moves to its title, and Escape or Close returns it to the marker or the list row that opened it. It renders nothing while no place is open.

PropTypeDefaultDescription
asElementType'dialog'Another tag or component to render. The default is an open, non-modal dialog.
childrenReactNode | ((state) => ReactNode)–Without children: the picture, the title with Close, the body and the address, each only when the place has it. With nodes: exactly those, in your order, from the Map.Details parts or your own markup. With a function: the whole template, from { place, close, titleProps, side }. Keep a Map.DetailsTitle or put titleProps on your heading: it names the dialog.
Class or attributeValuesMeaning
--kv-map-popup-inline-sizea lengthThe width of a popup. The default is 22rem, and it never goes past the map.
--kv-map-popup-radiusa lengthThe corner radius of a popup. The default is the theme’s medium radius.
kv-map-details-footera classPut it on a row of your own actions at the end of the popup. It stays at the bottom while the content scrolls.

Map.DetailsImage, Map.DetailsTitle, Map.DetailsBody, Map.DetailsAddress, Map.DetailsClose

Renders The parts of a popup, for when you rearrange it. The picture is an <img> with the place’s alt, the title is an <h3> that names the dialog and takes focus, and Close is an icon button named “Close” plus the title. The picture, body and address render nothing when the place has none.

PropTypeDefaultDescription
asElementTypeimg, h3, p, pOn DetailsImage, DetailsTitle, DetailsBody and DetailsAddress: another tag for the part, such as h2 for the title. DetailsClose has no as.
childrenReactNodeThe place’s own textOn DetailsTitle (the place’s name), DetailsBody (its description) and DetailsAddress (its address). DetailsClose shows a close icon.

Map.ClusterPopup

Renders <dialog open> with the places of a cluster, in the same frame as the details. Only one of the two popups is open at a time. It renders nothing while no cluster is open.

PropTypeDefaultDescription
asElementType'dialog'Another tag or component to render. The default is an open, non-modal dialog.
childrenReactNode | ((state) => ReactNode)–Without children: the title with Close, then one button per place. With nodes: exactly those, from the Map.ClusterPopup parts. With a function: the whole template, from { cluster, close, select, titleProps, side }, where select(placeId) closes the popup and opens that place’s details.

Map.ClusterPopupPlaces

Renders A <ul> with a button per place and its address under it. Past 50 places it shows only the rows in view and is one Tab stop.

PropTypeDefaultDescription
renderPlace(place, select) => ReactNodeA button with the name and the address under itReplaces a row. Call select to open that place’s details.

Map.ClusterPopupTitle, Map.ClusterPopupClose

Renders The title (an <h3>, which takes focus and names the dialog) and the Close button of a cluster popup. The title takes as.

MapPlace

Renders nothing: it is the object you pass in places.

PropTypeDefaultDescription
idstringRequiredA stable id, used for the marker, the row and the focus.
namestringRequiredThe place’s name: the marker’s name, the list row’s text and the popup’s title.
position{ longitude: number; latitude: number }RequiredWhere it is.
layerstring–The id of the layer the place belongs to.
addressstring–Shown under the name in the list and in the popup.
descriptionstring–The body of the popup.
image{ src: string; alt: string }–The picture at the top of the popup. alt is required and in your language: use an empty string when the picture only decorates.
dataData–Your own object for the place, handed back to every render function.

MapLayer

Renders nothing: it is the object you pass in layers.

PropTypeDefaultDescription
idstringRequiredThe id a place names in its layer.
labelstringRequiredThe layer’s name, in the checkbox and in cluster names.
descriptionstring–Help text for the layer’s checkbox.
clusterbooleantruefalse: places of this layer are never grouped into clusters.

MapPlaceSource

Renders nothing: it is the object you pass in source, for a very large set of places.

PropTypeDefaultDescription
countnumberRequiredHow many places there are.
positionsFloat64ArrayRequiredLongitude and latitude of every place, interleaved: length count × 2.
layersUint16Array–For each place, the index of its layer in layers, or NO_LAYER (from @kvirn-ui/core) for none.
get(index: number) => MapPlace | Promise<MapPlace>RequiredThe place at an index, built when a marker, a row or a popup needs it. It may return a promise (a server call); a failed one is not tried again. placesToSource(places, layers) from @kvirn-ui/core shows the shape.

maplibre

Renders nothing: maplibre(options) from @kvirn-ui/map/maplibre returns the provider for MapLibre GL. MapLibre is an optional peer: install it only for this adapter. These are its options.

PropTypeDefaultDescription
stylestring | StyleSpecification–A MapLibre style document, or the URL of one. There is no default: you choose the tile source. Use style or baseMaps.
baseMapsreadonly { id, label, attribution?, style }[]–Instead of style: a list of map types the visitor can switch between with Map.BaseMapSwitch.
defaultBaseMapstringThe firstWith baseMaps: the id to start on.
workerUrlstring–The URL of maplibre-gl/dist/maplibre-gl-worker.mjs. A bundler that pre-bundles dependencies (Vite in development) needs it.
attributionstring–Attribution that the style’s sources do not already carry.

rasterStyle

Renders nothing: rasterStyle(options) from @kvirn-ui/map/maplibre returns a MapLibre style from your own tile addresses, for maplibre({ style }). These are its options.

PropTypeDefaultDescription
tilesstring[]RequiredURL templates with {z}, {x} and {y} from your tile host. The library names none.
attributionstringRequiredThe source’s licence text. Show it with Map.Attribution.
tileSizenumber256The size of a tile in pixels.
minzoomnumber–The lowest zoom the source has.
maxzoomnumber–The highest zoom the source has.

createMemoryProvider

Renders nothing: createMemoryProvider(options) returns a provider with no engine. It keeps the camera, draws nothing and sends nothing, so it suits tests and pages with no picture. These are its options.

PropTypeDefaultDescription
size{ width: number; height: number }{ width: 800, height: 600 }The size the camera works with, in pixels. The provider draws nothing, so it cannot read the real size.
baseMapsreadonly MapBaseMap[]–Map types to list, so Map.BaseMapSwitch and Map.Attribution have something to show.
defaultBaseMapstring–The map type to start on.

createMapWorker

Renders nothing: a function from @kvirn-ui/map/worker that you pass as indexIn. The map creates the Web Worker when it builds the index of a large source and stops it afterwards, so you own nothing. The entry is ESM only.

useMap

The state behind Map.Root: it takes the same options and returns the same object as useMapState. Map.Root calls it for you, so you rarely need it.

Options

PropTypeDefaultDescription
providerMapProviderRequiredThe engine adapter that draws the map: maplibre({ style }), createMemoryProvider() or your own. Keep the same instance between renders.
labelstringRequiredThe map’s name, which a screen reader reads for the map region. Write it in your language: “Map of preschools”.
initialView{ center: { longitude, latitude }, zoom }RequiredWhere the map starts, and where the Whole map button returns to. Changing the prop later does not move the camera.
placesreadonly MapPlace[]–The places, up to a few thousand. Keep the array the same between renders. For more, use source.
sourceMapPlaceSource–The places as columns, for tens of thousands to millions. No object exists for a place until a marker, a row or a popup needs it. Use it instead of places, and keep it the same between renders.
indexIn'main' | (() => MapIndexer)'main'“main” builds the index of a large source on the page, in slices of 8 ms. Pass createMapWorker from @kvirn-ui/map/worker to build it in a Web Worker instead.
baseMapstring–The id of the active map type. Set it to control the map type yourself and update it in onBaseMapChange. Without it the map keeps its own.
defaultBaseMapstringThe provider’s, else the firstThe map type to start on when baseMap is not set.
onBaseMapChange(id: string) => void–Called with the id when a visitor picks a map type.
layersreadonly MapLayer[]–The groups of places. A place joins one with its layer. Keep the array the same between renders.
hiddenLayersreadonly string[]–The ids of the hidden layers. Set it to control them yourself and update it in onHiddenLayersChange.
defaultHiddenLayersreadonly string[][]The layers that start hidden when hiddenLayers is not set.
onHiddenLayersChange(ids: readonly string[]) => void–Called with the ids that are now hidden when a visitor shows or hides a layer.
clusterboolean | { radius?: number }trueGroups nearby places of one layer into a cluster. The radius is 64 CSS pixels, so two clusters stay about 44 pixels (one target) apart. false turns clustering off, and a layer with cluster: false is never clustered. A cluster holds places of one layer only.
messagesPartial<KvirnMessages["map"]>–Changes the map’s texts for this map. See Strings below for every key and its English text.

useMapState

Reads the map’s state inside Map.Root, so you can build a part the library does not render, such as your own list of places. It throws outside Map.Root. This is a selection of what it returns.

Result

PropTypeDefaultDescription
placesInViewMapPlace[]–The places in the map view, on a visible layer. It builds every place, so use it for a short list only.
visiblePlacesMapPlace[]–Every place on a visible layer. It builds every place too.
visibleCountnumber–How many places are on a visible layer.
placesInViewCountnumber–How many of them are in the map view.
getPlaceInView(index: number) => MapPlace | undefined–The place at a position in the list of places in view, in source order. Use it with placesInViewCount for a long list.
indexingboolean–True while the index of a large source is being built. Markers appear when it is done.
layerCountsRecord<string, number>–How many places each layer has.
layersreadonly MapLayer[]–The layers you passed.
hiddenLayerIdsreadonly string[]–The ids of the hidden layers.
setLayerHidden(layerId: string, hidden: boolean) => void–Shows or hides a layer. It closes a popup of a place or cluster on that layer and announces the new count.
markersInViewMapMarkerItem[]–The places and clusters drawn as markers.
selectedPlaceMapPlace | null–The place whose details are open.
openedClusterMapCluster | null–The cluster whose popup is open.
select(placeId: string, openerId?: string) => void–Opens a place’s details. Focus moves to the title, and closing returns it to the element with openerId.
close() => void–Closes the details.
openCluster(clusterId: string | null, openerId?: string) => void–Opens a cluster’s popup, or closes it with null.
clusterMarkerId(clusterId: string) => string–The id of a cluster’s button, for openCluster.
baseMapsreadonly MapBaseMap[]–The provider’s map types.
baseMapstring | null–The active map type’s id.
setBaseMap(id: string) => void–Changes the map type, keeps the camera and announces the change.
zoomIn() => void–Zooms in one step, or announces the limit.
zoomOut() => void–Zooms out one step, or announces the limit.
reset() => void–Returns to initialView.
viewMapView–The camera: center and zoom.
status'loading' | 'ready' | 'failed'–Whether the tiles have loaded.
messagesResolvedMessages–The map’s texts, with your overrides applied.
idsobject–The ids the parts use, such as details (for aria-controls) and listHeading (for your own list’s skip link).
show(target: MapPlace | AddressResult) => void–Centres the map on a place or an address, or fits the address’s bounds, without moving focus. A place also opens its details. An address draws the result pin and announces that the map shows it once the view settles.
searchResultAddressResult | null–The address that show drew a pin for, until clearResult.
clearResult() => void–Removes the result pin. It announces nothing.
setHighlightedPlaceId(placeId: string | null) => void–Highlights a marker and its row, as hovering one does.

Strings

These are the default texts in @kvirn-ui/i18n.

For your whole app, pass messages to KvirnProvider. For one Map, pass its messages prop.

The map’s texts exist in all five languages. Have a native speaker review the Swedish, Finnish and Norwegian ones before you launch. Your map’s label, your layer names and your place data are yours, so write them in the page’s language.

Message keyParametersDefault text in EnglishUsed for
roleDescription–mapThe role a screen reader says for the map region.
summarycountThe map shows 12 places. The same places are in the list.Read after the map’s name: how many places are drawn.
keyboardHint–Move the map with the arrow keys. Zoom with + and −.The hint on the map until the next interaction.
skipToList–Skip the map, go to the list of placesThe text of the skip link.
controlsLabel–Map controlsThe name of the group of control buttons.
markersLabel–Places in the map viewThe name of the group of markers.
zoomIn–Zoom inThe name of the zoom in button.
zoomOut–Zoom outThe name of the zoom out button.
zoomLimitIn–You can't zoom in any further.Announced when the map cannot zoom in any further.
zoomLimitOut–You can't zoom out any further.Announced when the map cannot zoom out any further.
reset–Whole mapThe text of the button that returns to the start view.
panNorth–Move the map northThe name of the pan north button.
panSouth–Move the map southThe name of the pan south button.
panEast–Move the map eastThe name of the pan east button.
panWest–Move the map westThe name of the pan west button.
placesInViewcount12 places in the map view.Announced after the view settles, and the list’s heading, when some places are out of view.
placesAllcount12 places.Announced, and the list’s heading, when every place is in view.
loading–Loading the mapShown in the viewport while the map loads.
tilesFailedTitle–The map can't be shown right nowShown, and announced once, when the tiles fail.
tilesFailedBody–You can still find every place in the list.Shown under the failed title: the list still works.
gestureTouch–Use two fingers to move the mapThe hint when one finger is used on a touch screen.
gestureWheelmodifierHold Ctrl and scroll to zoom the mapThe hint when the wheel is used without the modifier key.
detailsClose–CloseThe first part of the popup’s Close name.
listEmpty–There are no places in the map view. Zoom out or move the map.Shown in place of the list when no place is in view.
indexing–Loading the placesAnnounced once while the index of a large source builds.
attributionLabel–Map dataThe name of the attribution text.
baseMapLabel–Map typeThe name and legend of the map type switch.
baseMapChangedlabelMap type: Satellite.Announced when the visitor changes the map type.
clusterLabelcount12 placesThe name of a cluster button.
clusterLayerLabelcount layerHotels: 12 placesThe name of a cluster button when it belongs to a layer.
clusterTitlecount12 placesThe title of a cluster popup.
clusterLayerTitlecount layerHotels: 12 placesThe title of a cluster popup when it belongs to a layer.
clusterClose–CloseThe first part of a cluster popup’s Close name.
layersLegend–Show on the mapThe title of the layers card and its button.
layersHiddenValuecount3 hiddenAfter the title while the card is collapsed and layers are hidden.
layerCountValuecount100The count after a layer’s name in its checkbox.

Known issues#

  • Review the translations before you launch. Have a native speaker review the Swedish, Finnish, Norwegian Bokmål and Norwegian Nynorsk texts before you launch. Override any text with the messages prop or the provider's map catalog. Your own map label, layer names and place data are in your language already.
  • Markers under the floating cards cannot be pressed there. Where the Layers or Map type card covers a marker, use the list or the keyboard, which pans the marker clear (2.4.11).
  • Test with your users and their assistive technology. A map is hard to make equal for everyone, so check the viewport, the layer checkboxes, the pan buttons and the list with the assistive technology your users have.
  • Markers of different layers can touch. Layers cluster separately, so a cluster of one layer can sit on a marker or cluster of another. Every place stays reachable from the keyboard (arrow keys between markers) and in the list.
  • cluster={false} with a large source puts every place in view on the page as a button. The map warns once in development past 2,000 markers, and does not cap them. Keep clustering on, or turn it off only for small layers.
  • The map has no address search of its own. To let a visitor search for an address, put an AddressSearch beside the map (address-search.a11y.md). A visitor otherwise finds a place by the markers, the list and the layers.

Information: Did you know?

If an issue here affects your service, list it in your accessibility statement with its workaround.

Testing#

The automated tests prove the keyboard behaviour, the names and states, that axe finds no violations in every story and theme, and, for the components they cover, that the stories hold up in forced colours, reduced motion, text spacing and a 320 pixel width. An Automated row passes on these tests alone. A Core or Release row passes only when an automated agent check and a person on the real assistive technology have both checked it. "agent-verified" means automated tests in the repository (with a virtual screen reader for the screen reader rows), not the real assistive technology.

AT + browser + OSAgent checkHuman checkResultNotes
Automated (re-runnable tests)
axe, WCAG 2.2 A and AA, every story, 4 themespassn/apassmap.stories.tsx, every story, 4 themes
Markup and ARIA (roles, names, ids, states)pendingn/apendingthe test has no axe check
Keyboard contract rows (Vitest browser)passn/apass35 rows, each names a test (map.test.tsx › Tab reaches the skip link and the viewport)
Focus order and managementpassn/apassmap.test.tsx asserts focus (toHaveFocus); first rule: Tab reaches the skip link and the viewport
Display modes (forced colours, 320px reflow, text spacing, reduced motion)pendingn/apendingmap is in sweepComponents (vite.config.ts), so the four sweep projects run its stories in CI
Core (required for beta)
NVDA + Chrome + Windowspendingpendingpending
VoiceOver + Safari + iOSpendingpendingpending
Release (before 1.0 and each minor)
JAWS + Chrome + Windowspendingpendingpending
TalkBack + Chrome + Androidpendingpendingpending
VoiceOver + Safari + macOSpendingpendingpending

Information: Did you know?

The map is checked with automated accessibility tests and keyboard tests. Test with the assistive technology your residents use before you rely on the map, and keep the list.