Skip to content
NewYour data: charts, lists and meters that take your records
<GeoRegionPicker />ReactInputs & timeForm control

Region picker

Pick a deployment region from a list with a dot map. The reticle travels along the great circle, magnifying the land dots it passes.

View as Markdown
<GeoRegionPicker />

Tryuse the arrow keys: Up and Down follow the list, Left and Right jump west or east on the map.

Your data

Pass your regions as regions and the user's location as from. Without regions the picker shows 16 demo regions; nothing about the viewer's location is read or inferred. See Your data.

Playground

Change a prop and the component re-renders. Props marked remounts set an initial value, so the component starts over.

Loading <GeoRegionPicker />
Props
defaultValueremounts
layoutlive
stretchlive
disabledlive
labellive
React
<GeoRegionPicker
  from={{
    lat: 40.4168,
    lon: -3.7038,
    label: "Madrid office"
  }}
  defaultValue="eu-central"
  layout="both"
  stretch={1.5}
  label="Region"
/>

Installation

pnpm dlx shadcn@latest add @lumesec/geo-region-picker
First timeRegister the @lumesec registry once, or install by URL

Adds @lumesec to your components.json:

pnpm dlx shadcn@latest registry add @lumesec=https://elements.lumesec.ai/r/{name}.json

Or skip the setup and install by URL:

npx shadcn@latest add https://elements.lumesec.ai/r/geo-region-picker.json

Usage

geo-region-picker-example.tsx
import { GeoRegionPicker } from "@/components/lumesec/geo-region-picker";

export function Example() {
  return (
    <form>
      <GeoRegionPicker name="region" defaultValue="eu-west" from={{ lat: 40.4168, lon: -3.7038, label: "Madrid office" }} />
    </form>
  );
}

Behaviour

Pick a deployment region from a list with a map above it. The selection reticle travels to the new region along the great-circle path with a comet tail, and the land dots under it are magnified as it passes.

Give it a from location and every region shows an estimated round trip, with a dotted line from that location to the region you point at. It submits with forms through a hidden input.

API reference

Props

Also accepts every prop of <div> (React.ComponentProps<"div">), spread onto the root element.

valueTypestring

Selected region id (controlled). Use with onValueChange. An id that is not in regions shows no reticle and no checked radio.

defaultValueTypestringDefault"eu-central"

Selected region id when uncontrolled. A form reset restores it.

onValueChangeType(value: string) => void

Called with the region id when the user picks a region.

regionsTypereadonly GeoRegion[]DefaultDEMO_REGIONS

Regions in list order: { id, label, city, timeZone, lat, lon }. Regions with a repeated id or a non-finite position are skipped. Without it the picker shows the 16 demo regions. An empty array shows "No regions".

fromTypeLatLon & { label?: string }

Location the latency hints are measured from. It shows on the map as a small accent square with label (default From) beside it. Without it there are no hints and no lines.

stretchTypenumberDefault1.5

Path stretch over the fibre minimum for the hints: a hint is round(2 × distance / 204 km per ms × stretch).

layoutType"both" | "map" | "list"Default"both"

both: the map above the list. map: the map above a compact wrap of chips. list: the list without the map.

nameTypestring

Form field name of the hidden input that carries the selected region id.

requiredTypebooleanDefaultfalse

Sets aria-required on the radiogroup.

disabledTypebooleanDefaultfalse

Dims the picker, ignores the pointer and takes the radios out of the tab order.

labelTypestringDefault"Region"

Visible heading of the list, and the accessible name of the radiogroup.

Ref

ref points at the root HTMLDivElement.

Keyboard

KeysAction
TabMoves focus to the selected radio, or to the first one when nothing is selected.
ArrowDown / ArrowUpSelects the next or previous region in the list, wrapping at the ends.
ArrowRight / ArrowLeftSelects the nearest region east or west on the map. Past the last region that way it continues around the globe.
Home / EndSelects the first or last region.
Space / EnterSelects the focused region.

Accessibility

  • The list (or the chips with layout="map") is a role="radiogroup" labelled by the visible heading, with one tab stop. Each region is a button with role="radio" and aria-checked.
  • Each radio's accessible name is the label and the city, plus the hint when from is set, such as "eu-west, Dublin, about 21 ms round trip".
  • required sets aria-required and disabled sets aria-disabled on the group.
  • The map, its canvases and its 24 px pointer targets are aria-hidden; the targets are not in the tab order. Picking a region on the map moves focus to its radio.
  • Keyboard focus on a radio draws the same line from from as pointing at it.
  • With name and a selected region, a hidden input submits the region id under that name. Nothing is submitted while no region is selected; required does not block submission. A form reset restores defaultValue.
  • Reduced motion: the reticle jumps to the new region with no comet, sparks or bracket snap, the lens stays at its resting strength, the line from from appears without drawing on, and the hints and the header value change without rolling.

Theming

Styled with Tailwind classes on your shadcn theme tokens, so light and dark follow your theme. The accent comes from --lumesec. See Theming.

This component reads --lumesec, --lumesec-glint, --card, --muted, --muted-foreground, --foreground and --border.

Notes

  • The map is an Equal Earth strip from 50° S to 72° N, drawn from the embedded world data with no map tiles. Regions outside that band sit on the nearest edge.
  • The reticle's progress is a spring whose stiffness falls with distance (180 × √(5000 / max(km, 500))), so long trips take longer. A trip across the 180° meridian leaves one edge of the map and comes back in at the other. A change during travel starts the new trip from where the reticle is.
  • The lens is a 28 px disc around the reticle: land dots inside it are pushed outward, enlarged and tinted toward the accent, most at the centre. It is strongest in flight and stays on the selected region at 0.6 strength.
  • The hints are estimates from the great-circle distance, not measurements. With layout="map" the chips have no hints; the header shows the selected region's hint instead.
  • Regions close together share the map's pointer targets; a press picks the region nearest to the pointer.

Was this page helpful?