Xzero UI
Pro library

Choropleth explorerPro

A filled-region map that shades every state or region by revenue, growth or penetration on a stepped scale, with a country switch (United States, Canada, Brazil, United Kingdom, France, Germany, Italy, Australia), a hoverable legend, a synced ranked list and a camera zoom into local detail.

$ pnpm dlx shadcn@4.23.0 add @xzero-ui-pro/choropleth-explorer
Live · keyboard ready

Render <ChoroplethExplorer /> for the demo, or pass your own regions (SVG paths, values per metric, optional subregions) and metrics. Listen to onRegionOpen and onMetricChange to sync the zoomed region or metric with the URL.

When to use

When not to use

Installation

Register both Xzero UI namespaces in your project's components.json:

{
  "registries": {
    "@xzero-ui": "https://mcp.xzero.co.uk/r/{name}.json",
    "@xzero-ui-pro": "https://mcp.xzero.co.uk/r/pro/{name}.json"
  }
}
npx shadcn@4.23.0 add @xzero-ui-pro/choropleth-explorer

Install xzero-foundation once, and import @/components/xzero/foundation.css in your app root. No Xzero token is used by this snapshot. For sample portraits, photos, fonts, or logos, download https://mcp.xzero.co.uk/install-assets.mjs and run node xzero-install-assets.mjs <receiving-project>.

Usage

import { ChoroplethExplorer } from "@/components/xzero/blocks/choropleth-explorer/choropleth-explorer";

export function SalesByRegion() {
  return (
    <ChoroplethExplorer
      defaultMetric="growth"
      onRegionOpen={id => router.replace(id ? `?state=${id}` : "?")}
    />
  );
}

API reference

ChoroplethExplorer

A filled-region map that shades every state by a metric on a stepped sequential or diverging scale. A metric switch sweeps the new fills across the map from west to east, the legend steps light every region in their bin, a ranked list stays in sync with the map both ways, and selecting a state zooms the camera into it and shades its counties.

PropTypeDefaultDescription
mapsChoroplethMap[]choroplethMapsAreas to switch between, such as countries: an id, a name, its regions, a plural region noun, an optional title, metrics (for a local currency) and view box. A country switch appears when there is more than one. Ignored when regions is set.
defaultMapstring–Id of the area shown first. Defaults to the first one.
onMapChange(id: string) => void–Called after the area changes.
regionsChoroplethRegion[]–Top level regions of a single area: an id, a name, SVG path data in view box units, an optional bounding box, one value per metric id (null for no data) and optional subregions with their own paths and values.
metricsChoroplethMetric[]choroplethMetricsMetrics in the switch. Each has a label, a headline label, a format ("currency", "change" or "percent"), a scale ("sequential" or "diverging") and how the headline aggregates ("sum", or "weighted" by the first metric).
defaultMetricstring–Id of the metric shown first. Defaults to the first metric.
viewBox[number, number][975, 610]Width and height of the view box the region paths are drawn in.
areaNamestring"United States"Name of the whole area, shown above the map before zooming in.
regionNounstring"states"Plural noun for top level regions, used in the list heading, legend and announcements.
titlestring"Revenue by state"Heading of the block.
descriptionstringchoroplethCaptionLine under the title. Pass an empty string to hide it.
onRegionOpen(id: string | null) => void–Called after the map zooms into a region, with its id, or with null when it zooms back out.
onMetricChange(id: string) => void–Called after the metric changes.
classNamestring–Class on the root element.

Keyboard interactions

KeysAction
TabMoves to the metric switch, the back button when zoomed in, the legend steps and the ranked list.
Arrow up / Arrow downIn the ranked list, moves between regions and outlines the focused one on the map.
Home / EndIn the ranked list, jumps to the first or last region.
Enter / SpaceOn a state, zooms into it and lists its counties. On a county, pins it on the map. On a legend step, keeps its regions lit until pressed again.
EscapeReleases a pinned legend step, then zooms back out to every state.

Accessibility

Motion

Responsive behavior

Performance

Notes for AI

Guidance for AI tools

Blocks are complete, self-contained screens with sample data. Replace the sample data and connect the callbacks described above. Follow the declared prop types and do not invent props. Keep keyboard access, reduced motion support, and both light and dark themes intact when adapting it.

Full library index: https://ui.xzero.co.uk/llms.txt

Browse all components