Skip to content

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

Fleet Tracker Map Block for React

Replay a trucking shift in Southern California: six trucks on real road loops, a time slider from 06:00 to 18:00, a Play button and live status cells.

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

See where every truck was at any time of the day, with this fleet tracker map for React with Base UI. Haulwick, a trucking fleet, runs six trucks across Southern California, each on a loop of real roads between the ports of Long Beach and Los Angeles, the Inland Empire, the high desert and the valleys, drawn on a live Map that follows your theme. Under the map, a dock holds the time of day: a Slider from 06:00 to 18:00 in ten-minute steps, and an outline Play button that steps through the shift and stops at 18:00 (it stays off under reduced motion). Each truck's typed plan of drives, unloading, a break and the drive home places its numbered pill on its loop by distance along the road, draws the part already driven solid over the faint road ahead, and sets its status: Driving, Unloading, On break, Not out yet or Parked, each with its own icon. Six cells under the dock follow the time with the status, where to and the kilometres done; choosing one flies the map to that truck's loop, names its calls and draws it in the primary colour. Built from Map, Slider, Button and Guides. For trucking and haulage firms, fleet managers and logistics dashboards.

FAQ

How does the replay place each truck?

Each truck has a typed plan, such as 06:00 D;06:40 S;07:40 D: D drives the next leg of the loop, S unloads, B is a break and E is parked back at the yard. stateAt finds the step at the chosen time; while driving, the truck's share of the loop grows evenly from the end of the last leg to the end of this one, measured along the road. The pill sits at that share of the route and the solid line runs up to it.

Are the routes real?

Yes. Each loop is a road route from the OSRM demo service, asked once while the block was written, simplified and typed into TRUCK_LINES; nothing is fetched while it runs. The places are real: the ports, Commerce, Ontario, Victorville, Temecula and the rest. Haulwick, the drivers and the plans are sample data.

How does Play work, and can I stop it?

Play moves the time on ten minutes every 350 milliseconds and stops at 18:00, or when you press Pause or touch the slider. With reduced motion on, it doesn't run and says so under the time: drag the slider instead. The map itself never moves on its own.

What happens when I choose a truck?

Its cell stays pressed, the map flies to its loop, the loop turns the primary colour and its yard and two calls are named on the map while the other loops and their pills fade. Press the cell again, or the frame button by the zoom buttons, to see all six loops again.

Can I use it from the keyboard?

Yes. Play is a button, the slider moves with the arrow keys (Page Up and Page Down jump, Home and End go to 06:00 and 18:00) and reads the time aloud, and each truck's cell is a toggle button. Every truck's status is in its cell, so nothing depends on the map; a polite message gives the counts once the slider rests.

How does it look on a phone?

The map comes first, then the Play button and the time with the slider under it, then the six trucks in two columns. The page scrolls over the map; two fingers pan it.