Base · Data display
Map
Shows places on an interactive map that can be panned and zoomed.
Props
import { Map } from "@/components/ui/map"
const depots = [
{ id: "west-loop", lngLat: [-87.6513, 41.8845], label: "West Loop Hub", description: "Main depot · 42 parcels out today" },
{ id: "ohare", lngLat: [-87.9073, 41.9786], label: "O'Hare Cargo", description: "Air freight · next pickup 14:30" },
{ id: "midway", lngLat: [-87.7522, 41.7868], label: "Midway Depot", description: "Returns and overflow" },
{ id: "pilsen", lngLat: [-87.6617, 41.8556], label: "Pilsen Cross-dock", description: "Stop 4 · ETA 11:05" },
{ id: "lincoln-park", lngLat: [-87.6475, 41.9214], label: "Lincoln Park Stop", description: "Stop 5 · ETA 11:40" },
]
<Map center={[-87.78, 41.885]} markers={depots} label="Chicago depots and stops" className="h-[300px] w-[520px] max-w-full" />React: MapLibre GL (maplibre-gl on npm) with OpenFreeMap tiles; loaded in the browser only. A Google Maps or Apple MapKit adapter can implement the same props where a client licenses them.
Overview
A map plots locations, such as depots, stops or customer sites, on a vector basemap that follows the theme. It is provider-agnostic: MapLibre GL with free OpenFreeMap tiles is the default because it needs no API key or account, and Google Maps or Apple MapKit can sit behind the same props when a client already licenses them (both need API keys).
When to use
- When where something is matters: depots, delivery stops, store locations, a shipment's position.
- To let people explore an area by panning and zooming, and open a location for details.
- Next to a list or Table of the same locations, which stays the main way to scan and act on them.
When not to use
- For a single address that people only need to read or copy: show the address as text, with a link out to a maps app.
- To compare quantities by region: use a chart or a Table; a map makes small regions hard to read.
- As decoration in a small Card: it costs a large download and traps scrolling; use a static image instead.
Anatomy
Container
Clips the map with a border and radius.lg corners.
Basemap
Vector tiles drawn with WebGL. The appearance prop picks a light, dark or colorful street style.
Markers
Numbered pins in color.intent.brand.solid with color.intent.brand.on-solid text. Each is a button.
Popup
Opens on a marker with its label and details, on the raised surface with shadow.md.
Zoom controls
Zoom in and out buttons, shown when the map is interactive.
Attribution
OpenFreeMap, OpenMapTiles and OpenStreetMap credits. Required by the data licenses; always visible.
Props
The contract every language implements. Names follow each language’s conventions (camelCase in React, snake_case in Rust).
| Prop | Type | Default | Description |
|---|---|---|---|
| appearance | "auto" | "light" | "dark" | "streets" | auto | Basemap style. auto matches the light or dark mode; streets is the colorful style. |
| zoom | number | 9 | Zoom level, from 0 (the world) to about 18 (a street). 9 shows a city and its suburbs. |
| showMarkers | boolean | true | Shows the markers. Example data: five Chicago depots and stops. |
| interactive | boolean | true | Allows panning, zooming and rotating, and shows the zoom buttons. Turn off for a fixed overview. |
| center | string | – | [longitude, latitude] of the initial view, e.g. [-87.78, 41.885]. `data-center="-87.78,41.885"` in HTML. |
| markers | string | – | Array of { id, lngLat: [lng, lat], label, description? }. In HTML, a <script type="application/json"> child of the map. |
| label | string | – | Accessible name of the map region, e.g. “Chicago depots and stops”. aria-label in HTML. |
| onMarkerClick | function | – | Called with the marker when it is pressed. In HTML, listen for the pdc-map:marker event. |
States
- Loading
- The container shows the muted background until the first tiles arrive.
- Interactive
- Drag to pan, scroll or pinch to zoom; the zoom buttons are shown.
- Static
- interactive off: gestures and keys do nothing and the zoom buttons are hidden. Markers still open.
- Marker open
- A popup shows the marker's label and details. Escape, the close button or a click on the map closes it.
- Focus-visible
- The map or a marker shows the focus ring in color.border.focus.
Accessibility
Role: region
| Keys | Action |
|---|---|
| Tab | Moves focus to the map, then to each marker. |
| Arrow keys | Pans the map when it has focus (interactive only). |
| +/= | Zooms in (interactive only). |
| -/_ | Zooms out (interactive only). |
| Shift + Arrow keys | Rotates (left, right) and tilts (up, down) the map (interactive only). |
| Enter/Space | Opens the popup of the focused marker. |
| Escape | Closes the open popup. |
- A map is not readable by screen readers. Always give a text alternative: the component renders a visually hidden list of the locations, and the page should also show them as a list or Table.
- Give the map an accessible name with label (aria-label in HTML) that says what it shows.
- Markers are buttons named after their location, so they can be reached and opened without a pointer.
- Keep the attribution visible: the OpenStreetMap and OpenFreeMap licenses require it.
Design tokens
Change any of these in Foundations and this component follows, in every language.
Platform notes
- HTML / JS
- Draft
- pdc.js builds the map from window.maplibregl, loaded from the CDN in the snippet. Follows the dark class on <html> for appearance="auto".
- React
- Draft
- MapLibre GL (maplibre-gl on npm) with OpenFreeMap tiles; loaded in the browser only. A Google Maps or Apple MapKit adapter can implement the same props where a client licenses them.
- React Native
- Planned
- Planned on react-native-maps (Apple Maps on iOS, Google Maps on Android) behind the same props.
- Swift (SwiftUI)
- Planned
- Not built in Swift yet.
- Godot
- Planned
- Not built in Godot yet.
- Vue
- Draft
- Usage snippet only; same props and behavior as the React component.
- Svelte
- Draft
- Usage snippet only; same props and behavior as the React component.
- Solid
- Draft
- Usage snippet only; same props and behavior as the React component.