Map
A generic, interactive geographic map. Choose a map variant, shade individual regions, attach custom tooltips, and react to hover and click events. The USA, World, Canada, and Europe variants ship today; additional variants add their own geography under the same API. An optional legend renders below the map.
Demo
USA
The default map variant, set with mapvariant="USA", for a state-level map. Regions are keyed by USPS state abbreviation codes; unlike the other variants, state names are read directly from the underlying topology rather than localized.
| Code | Name |
|---|
World
Set mapvariant="World" for a country-level map. Regions are keyed by ISO 3166-1 alpha-2 country codes, and country names are localized the same way the map's own accessible label is.
| Code | Name |
|---|
Canada
Set mapvariant="Canada" for a province/territory-level map. Regions are keyed by ISO 3166-2:CA subdivision codes, and province/territory names are localized the same way the map's own accessible label is.
| Code | Name |
|---|
Europe
Set mapvariant="Europe" for a country-level map scoped to Europe. Regions are keyed by ISO 3166-1 alpha-2 country codes (reusing the World variant's topology and localized country names), and country names are localized the same way the map's own accessible label is.
| Code | Name |
|---|
Legend
Pass legend to render a swatch + label row below the map, plus a disclaimer caption. x-map does not auto-assign colors — supply one per entry. See Choosing legend colors below for the sequential/categorical/colorblind-safe guidance.
Non-interactive
Set interactive="false" and showtooltips="false" for a purely presentational map.
API
Tag
| Name | Description |
|---|---|
<x-map> |
Custom HTML tag. |
Attributes
| Name | Value | Required | Description |
|---|---|---|---|
mapvariant |
String |
Which map to render. Each variant ships its own geography. Today |
|
regions |
JSON array of region objects. See Guidelines below. |
Per-region configuration. Accepts an array (via property) or a JSON string (via attribute). Default: |
|
defaultfill |
String |
Fill applied to regions without an explicit |
|
strokecolor |
String |
Color of the borders drawn between regions. Accepts any CSS color. Default: |
|
strokewidth |
Number or String |
Width of the borders drawn between regions. Default: |
|
interactive |
Boolean |
When |
|
showtooltips |
Boolean |
When |
|
allowhtmltooltips |
Boolean |
When |
|
legend |
JSON array of legend entries. See Choosing legend colors below. |
Legend entries rendered as a swatch + label row below the map, plus a disclaimer caption, whenever non-empty. Accepts an array (via property) or a JSON string (via attribute). Default: |
|
i18n |
string |
A stringified JSON object which defines a list of localized strings. The keys must be one of the string IDs defined below. |
Properties
| Name | Value | Required | Description |
|---|---|---|---|
mapVariant |
XMapVariant ('USA' | 'World' | 'Canada' | 'Europe') |
Which map to render. Defaults to |
|
regions |
XMapRegionData[] or JSON string |
Per-region configuration. Recommended way to pass data, since it accepts a live array. See Guidelines. |
|
defaultFill |
String |
Fill applied to regions without an explicit |
|
strokeColor |
String |
Color of the borders drawn between regions. |
|
strokeWidth |
Number or String |
Width of the borders drawn between regions. |
|
interactive |
Boolean |
When |
|
showTooltips |
Boolean |
When |
|
allowHtmlTooltips |
Boolean |
When |
|
legend |
XMapLegendItem[] or JSON string |
Legend entries rendered below the map, plus a disclaimer caption, whenever non-empty. See Choosing legend colors. |
|
i18n |
object |
A JSON object which defines a list of localized strings. The keys must be one of the string IDs defined below. |
Events
| Name | Detail | Description |
|---|---|---|
s-mapregionclick |
XMapRegionEventDetail |
Fires when an interactive region is clicked or activated via keyboard (Enter/Space). |
s-mapregionhover |
XMapRegionEventDetail |
Fires when the pointer enters an interactive region. |
s-mapregionleave |
XMapRegionEventDetail |
Fires when the pointer leaves an interactive region. |
Demo
API
Tag
| Name |
|---|
<XMap> |
Props
| Name | Value | Required | Description |
|---|---|---|---|
mapVariant |
XMapVariant ('USA' | 'World' | 'Canada' | 'Europe') |
Which map to render. Defaults to |
|
regions |
XMapRegionData[] |
Per-region configuration. See Guidelines. |
|
defaultFill |
String |
Fill applied to regions without an explicit |
|
strokeColor |
String |
Color of the borders drawn between regions. |
|
interactive |
Boolean |
When |
|
allowHtmlTooltips |
Boolean |
When |
|
legend |
XMapLegendItem[] |
Legend entries rendered below the map, plus a disclaimer caption, whenever non-empty. See Choosing legend colors. |
|
onS-mapregionclick |
Function |
Fires when an interactive region is clicked or activated via keyboard. The region details are available on |
|
onS-mapregionhover |
Function |
Fires when the pointer enters an interactive region. |
|
onS-mapregionleave |
Function |
Fires when the pointer leaves an interactive region. |
Skylab React links
Typescript
Exported types
Guidelines
Choosing a map
Use the mapvariant attribute to select which geography renders. The component ships with
USA, World, Canada, and Europe variants today; each new variant adds its own topology and is selected by
the same prop. Shading and tooltips work identically across variants — only the set of region
code/name keys changes per map. An unknown variant falls back to USA.
Setting region data
Provide a regions array (or stringified JSON) where each entry targets one region by
code (preferred) or full name. Regions you do not list fall back to
defaultfill.
fill— any CSS color, including design-system custom properties such asvar(--color-blue-medium).className— apply a class to the region's path to drive its fill from CSS instead offill.tooltip— tooltip content. Plain text by default; setallowhtmltooltipsto render rich HTML.value— arbitrary data echoed back in interaction events, useful for wiring custom UI.disabled— render the region but exclude it from hover, focus, and click handling.
Choosing legend colors
x-map renders whatever color each legend entry supplies — it does not
assign colors itself. Pick a set from chart-css-utils.ts, the same source every other
Skylab chart reads from, so map legends stay consistent with bar, donut, and line-chart legends:
- Up to 5 colors that represent ordered steps of one measure — use the sequential set (
sequentialPalette(count)), anchored on--gradient-teal-mediumand grown outward (dark→light). A stacked/ranked view is a good fit. - More than 5 colors, or colors that label unrelated categories rather than ordered steps — use the categorical set (
CATEGORICAL_PALETTE):teal-medium → blue-dark → purple-dark → gold-medium → blue-medium → teal-lightest → purple-light → gold-light. - Verify the chosen set against deuteranopia and protanopia (red-green color blindness) before shipping, since adjacent categorical slots can read as the same hue under those conditions. Do not rely on hue alone to distinguish regions — pair the legend with the
labeltext, which is always visible regardless of color perception.
See Charts, gauges, KPIs in the token system docs for the full palette and legend spec.
Accessibility
The map renders as an <svg role="img"> with an accessible label (overridable via
aria-label). Interactive regions expose role="button", are focusable, and can be
activated with the keyboard. Provide meaningful label values for screen-reader users.
Design
Design resources can be found on the Skylab design documentation site: skylab.avalara.com