Theming

All map colors are driven by CSS variables, registered as Tailwind theme colors. Override them globally in your CSS or inline per-component via className.

CSS variables

These variables are injected into your project when you install any map component.

Region colors

VariableTailwind classDescription
--map-regionfill-map-regionDefault region fill
--map-region-hoverfill-map-region-hoverFill on hover
--map-region-selectedfill-map-region-selectedFill when selected
--map-region-disabledfill-map-region-disabledFill when disabled

Stroke colors

VariableTailwind classDescription
--map-region-strokestroke-map-region-strokeDefault border between regions
--map-region-stroke-hoverstroke-map-region-stroke-hoverBorder on hover
--map-region-focus-ringstroke-map-region-focus-ringKeyboard focus ring color

Label colors

VariableTailwind classDescription
--map-labeltext-map-labelAbbreviation label color
--map-label-hoverLabel color on hover
--map-label-selectedLabel color when selected

Override globally

Add overrides to your globals.css after the shadcn import:

css
:root {
  --map-region: oklch(60% 0.15 145);
  --map-region-hover: oklch(50% 0.18 145);
  --map-region-selected: oklch(45% 0.22 145);
}

Dark mode

Dark mode values are included by default. Override them in the .dark selector:

css
.dark {
  --map-region: oklch(55% 0.12 145);
}

Per-region colors

Pass any Tailwind color class to a region via the regions prop:

tsx
<USAMap
  regions={[
    { id: 'CA', className: 'fill-emerald-500 hover:fill-emerald-600' },
    { id: 'TX', className: 'fill-amber-500 hover:fill-amber-600' },
  ]}
/>

Choropleth pattern

For data-driven coloring, compute className dynamically:

tsx
const regions = data.map(({ id, value }) => ({
  id,
  className: value > threshold ? 'fill-blue-600' : 'fill-blue-200',
}))

<USAMap regions={regions} />