Skip to content

shadcn.io is an independent project built on shadcn/ui

Driver Assignment Map Block for React

Eleven Manchester stops given to five drivers by a select on each row, with load bars that say Over by 20 kg and one line style per driver's run.

On this page5 sections

Preview

Preview width

Installation

Part of Pro
Pro unlocks the code and one-line install of every Pro button and text effect, plus the MCP for your AI editor.
Have Pro already? Sign in to open it.Opens here as soon as you're Pro.

Overview

Balance the day's loads before the vans leave, with this driver assignment map for React with Base UI. Haulmoor, a courier operations tool, plans a day out of a depot in Trafford Park: eleven stops in real Manchester neighbourhoods, from Eccles to Levenshulme, sit on a live Map that follows your theme, and five drivers share them. Each stop is given to a driver with a Native Select on its table row (five rows, then "Show 6 more"), and the band over the map has a cell per driver: a bar that fills against the van's capacity, the kilos as words, and past the capacity "Over by 20 kg" with a warning icon. Each driver's run leaves the depot for the nearest stop left, as the crow flies, and has its own line style (solid, dashed, dotted, long dash, dash-dot), and each pin carries its driver's letter, so nothing depends on colour. Pressing a driver's cell, or one of their pins, flies the map to that run and quiets the others; the foot counts the drivers over capacity. The day starts with two over: move a stop or two and watch the count fall. Built from Map, Native Select, Button and Guides. For courier and logistics teams, field service planners and anyone splitting work by capacity.

FAQ

How are the loads and the over-capacity count worked out?

loadOf adds the weights of a driver's stops, and overOf is how far that is past the van's capacity. A driver over capacity gets a full bar and "Over by 20 kg" with a warning icon, and the foot counts them. The bar is decorative; the kilos are always in words beside it.

How is each run drawn?

visitsOf starts at the depot and goes to the nearest of the driver's stops left, again and again, measured as the crow flies; the run is a line through them, drawn with the driver's own dashes. It changes as soon as a stop changes driver. It is a sketch of the order, not a road route: plan the road route with your routing service when the runs are final.

What does pressing a driver do?

Each driver's cell is a toggle button. Pressed, the map flies to that driver's depot and stops, their run thickens and their pins turn solid, while the other runs fade and their pins shrink to dots. Press it again, or another pin's driver, to change or clear the focus. A pin on the map does the same as its driver's cell.

Is anything sent, and where does the data come from?

Nothing is sent: a change only updates the page. The depot and the neighbourhoods are real places in Manchester; Haulmoor, the drivers, the weights and the capacities are sample data in DRIVER_LINES and STOP_LINES. The map's tiles come from CARTO over OpenStreetMap, with their credit in the corner.

Can I assign stops without a mouse?

Yes. The driver cells are buttons, each stop's driver is a native select, and Show more is a button that says whether it is expanded. The map and its zoom buttons take the keyboard too; the pins are a pointer shortcut to the driver cells. A polite message gives the new load and the over-capacity count once a change settles.

How does it look on a phone?

The driver cells become a row you swipe sideways, the map comes next, and the table keeps the stop and its driver, with the weight under the stop's name. The page scrolls over the map; two fingers pan it.