Skip to content

World Map (Choropleth) for React

A React choropleth world map and bubble map on the Equal Earth projection, with no map library. Pass data as readonly WorldMapDatum[]: values by country (choropleth), or bubble sizes at each country's centre (mode="bubble").

npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/geo-map.json

Revenue by country

Arrow keys move to the neighbouring country, Page Up and Page Down step through them by value, Home and End jump to the highest and lowest. Type a name to jump to it. Plus and minus zoom, 0 resets.

  • WorldMap
  • WorldMapTable
  • defaultWorldMapLabels
  • +1 more

Choropleth map in React

Revenue by country on a single-hue scale, light to dark. One market dwarfs the rest, so scaleType="log" spreads the others across the ramp. Switch the measure: the map cross-fades to the new colors and the headline rolls to the new total. Hover a country, or focus the map and use the arrow keys; ⌘/Ctrl + scroll, pinch or the buttons zoom.

Revenue by country

Last 12 months, 45 markets

$15.5M

Diverging scale

Growth sits around a meaningful middle, so scale="diverging" uses two hues that meet at a neutral midpoint (0% here): orange for shrinking markets, blue for growing ones. The scale is symmetric, so equal changes get equally strong colors.

Year-over-year change in active users

2026 against 2025, by country

Files to copy

14 folders · 27 files · 4 packages
From theme/src/
  • components/charts/{geo-map.tsx, chart-export-menu.tsx, chart-export.ts, chart-figure.tsx, chart-fit.tsx, chart-icons.tsx, chart-parts.tsx, chart-patterns.tsx, chart-tip.tsx, chart-utils.ts, heatmap.tsx}
  • components/charts/geo/
  • components/charts/chart-parts/
  • components/charts/geo-map/
  • components/charts/heatmap/
  • components/drawer/parts/sheet.tsx
  • components/kbd/
  • components/menu/
  • components/skeleton/
  • components/status-icons/
  • hooks/{use-controllable.ts, use-intersection.ts, use-latest.ts, use-media-query.ts, use-preferences.ts}
  • motion/tokens.ts
  • lib/{cn.ts, csv.ts, form.ts, glide-highlight.tsx, heading.ts, math.ts, popup-a11y.ts, popup-motion.ts, warn-once.ts}
  • styles/
shadcn CLI
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/geo-map.jsonRegistry item: geo-map. The styles need the Tailwind v4 glass UI setup.
The examples also use
  • components/number-ticker/
  • components/spinner/
  • components/toast/
  • hooks/use-direction.ts
  • lib/{canvas-effects.ts, state-light.tsx}
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/number-ticker.json https://lokendra-builds.github.io/sheenui/r/toast.json
Packages
pnpm add @base-ui/react clsx motion tailwind-merge

Next.js: samples here pass functions (formatters, seriesLegend, a dashboard's load), so put them in a file that starts with "use client".

Bubble map

Bubbles at coordinates: their area follows the value, they keep their size on screen when you zoom, and a surface ring keeps neighbors apart. The size key reads in the same units.

Active users by city

Top 25 metro areas

Classed scale, any locale

steps={5} snaps colors to five classes, easier to match against the key. locale="de-DE" formats the numbers and names every country in German (Intl.DisplayNames).

Internetnutzer je 100 Einwohner

Gerundet, illustrativ

Props

PropTypeDefaultDescription
datareadonly WorldMapDatum[][]Values by country (choropleth), or bubble sizes at each country's centre (mode="bubble").
pointsreadonly WorldMapPoint[]NoneBubbles at coordinates (cities, offices). Drawn in bubble mode.
mode"choropleth" | "bubble""choropleth"Colour each country by its value, or size a bubble by it.
scale"sequential" | "diverging""sequential"Choropleth scale: "sequential" (one hue, light → dark: counts, rates) or "diverging" (two hues around a neutral midpoint: growth, change, sentiment).
midpointnumber0Value at the neutral centre of a diverging scale.
scaleType"log" | "linear" | "quantile""linear"How values spread over a sequential scale: "linear" (default); "log" for skewed data where one market dwarfs the rest (revenue, population); "quantile" ranks the values, so each colour holds about the same number of countries.
colorChartColor1Hue of the sequential scale and of bubbles: a palette slot 1–8.
divergingColors[ChartColor, ChartColor][2, 7]Hues below and above the midpoint of a diverging scale.
domain[number, number]the data's range (from 0 when every value is positive)The [min, max] the color scale spans; values outside it take the end colors.
stepsnumber0Classes on the scale (e.g. 5); 0 = continuous.
format((n: number) => string)compact numbers in localeFormats a region's value for the tooltips, legend and data table: takes the number, returns the text shown.
localestring"en"Locale of the number format and of country names (Intl).
valueLabelstringNoneName of the measure (legend caption, tooltip), e.g. "Revenue".
legendbooleantrueShow the colour (or size) key under the map.
zoomablebooleantrueAllow zooming and panning (buttons, ⌘/Ctrl + scroll, pinch, drag, + / −).
maxZoomnumber8Deepest zoom level: the map magnifies up to this many times its fitted size.
shapesreadonly WorldCountryShape[]NoneYour own outlines in the same frame (skips loading the bundled world).
onSelect((selection: WorldMapSelection) => void)NoneCalled with a country (or bubble) on click, Enter or Space.
emptyStateReactNodelabels.noData, applied from the labels objectShown over the map when there is no data. Default "No data".
labelsPartial<WorldMapLabels>defaultWorldMapLabelsEvery other string, for translation: labels={{ instructions: "…" }}; omitted keys keep the English of defaultWorldMapLabels. All 20 keys of WorldMapLabels are listed in the key table under the props table.
aria-label (required)stringNoneNames the chart for assistive tech (required).
classNamestringNoneAdds extra classes to the outer element.
WorldMapLabels keys and English defaults (20)
Pass any key in labels; the rest keep the defaults of defaultWorldMapLabels.
KeyEnglish default
instructionsArrow keys move to the neighbouring country, Page Up and Page Down step through them by value, Home and End jump to the highest and lowest. Type a name to jump to it. Plus and minus zoom, 0 resets.
instructionsBubbleArrow keys move to the nearest place in that direction, Page Up and Page Down step through them by value, Home and End jump to the highest and lowest. Type a name to jump to it. Plus and minus zoom, 0 resets.
roleDescriptionmap
noDataNo data
noDataKeyNo data
hintTap a country for its value
hintBubbleTap a bubble for its value
zoomInZoom in
zoomOutZoom out
resetZoomReset zoom
zoomControls(name) => `${name}: zoom`
zoomHint(mac) => (mac ? "Use ⌘ + scroll to zoom the map" : "Use Ctrl + scroll to zoom the map")
logScale(caption) => `${caption} (log)`
rank(rank, total) => `Rank ${rank} of ${total}`
loadErrorThe map could not be loaded.
rankHeaderRank
countryCountry
placePlace
valueValue
shareShare

WorldMapTable props

PropTypeDefaultDescription
datareadonly WorldMapDatum[][]Values by country (choropleth), or bubble sizes at each country's centre (mode="bubble").
format((n: number) => string)compact numbers in localeFormats a region's value for the tooltips, legend and data table: takes the number, returns the text shown.
mode"choropleth" | "bubble""choropleth"Colour each country by its value, or size a bubble by it.
pointsreadonly WorldMapPoint[]NoneBubbles at coordinates (cities, offices). Drawn in bubble mode.
labelsPartial<WorldMapLabels>defaultWorldMapLabelsEvery other string, for translation: labels={{ instructions: "…" }}; omitted keys keep the English of defaultWorldMapLabels. All 20 keys of WorldMapLabels are listed in the key table under the props table.
localestring"en"Locale of the number format and of country names (Intl).
valueLabelstringNoneName of the measure (legend caption, tooltip), e.g. "Revenue".
shapesreadonly WorldCountryShape[]NoneYour own outlines in the same frame (skips loading the bundled world).
sharebooleanfalseAdd a share-of-total column (for additive measures: revenue, users).
captionstringNoneSets a visually hidden caption that names the table.
emptyStateReactNodeNoneShown when there are no rows.

Keyboard

KeysAction
TabFocus the map (one stop), then the zoom buttons.
←/→/↑/↓Move to the neighboring country (or bubble) in that direction; it pans into view when zoomed.
Page Down/Page UpNext / previous place by value (rank order).
Home/EndHighest / lowest value.
LettersType a name to jump to it (type-ahead).
+/−Zoom in / out around the active place.
0Reset the zoom.
Enter/SpaceCall onSelect for the active place.
EscapeClear the active place; again to reset the zoom.

Accessibility

  • The map is one focusable figure with a role description of “map”; its accessible name ends with the keyboard instructions.
  • Keyboard moves are announced once through a polite live region (“India: 912K, Rank 2 of 45”); pointer hovers stay silent.
  • Missing values are hatched, never painted as the lowest color; the key includes a “No data” swatch.
  • The Table view lists every value ranked, with an optional share column: the color-free way to read the map.
  • Zoom buttons are real buttons (44px on touch), disabled at the limits; a plain scroll never hijacks the page.
  • Forced colors: borders become CanvasText and the active country gets a Highlight outline.

All exports on this page

  • WorldMap — World map: a choropleth (each country coloured on a sequential or diverging scale) or a bubble map (circles sized by value at each country's centre, or at any longitude / latitude).
  • WorldMapTable — Every value on the map as a ranked table: rank, country (or place), value and optional share.
  • defaultWorldMapLabels — The built-in English strings of WorldMap; spread it into your own labels and change what you need.

When to use the world map

  • Use it as a world map chart for a choropleth of year-over-year user growth by country, where equal changes get equally strong colors and the area of every country stays true to scale.
  • It fits a bubble map of active users by city, placing bubbles at longitude and latitude, with area following the value and a size key under the map. It is a React map without a map library: the bundled outlines are drawn by the chart itself, so Leaflet or Mapbox are not needed.
  • It also suits localized dashboards: pass locale, such as de-DE, and it formats the numbers and names every country with Intl.DisplayNames in that language.
  • Skip it when you need sub-country detail such as states, streets or routes; the bundled outlines are countries only, so reach for a dedicated mapping tool.
  • Pair it with ChartCard for the legend and Chart / Table tabs, WorldMapTable for a text table, and onSelect to show a country's detail in a Drawer or Popover.

Frequently asked questions

48 charts pages in all: browse them on Charts.

By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .