shadcn.io is an independent project built on shadcn/ui
On this page5 sections
Installation
Overview
Plan a trip across a city's trams and buses, with this transit routes map for React with Base UI. Tramhollow, a city transit agency, runs three tram lines (A, B and C, solid) and two orbital bus lines (D and E, dashed) along real streets of Leeds, drawn on a live Map that follows your theme, with fifteen stops at real places, the line letters on tiles at each line's ends and a larger ring at every interchange. Two Native Select menus pick where you start and where you are going, a Button swaps them, and pressing a stop on the map makes it the destination. The route is the one with the fewest changes, then the quickest: a ride on one line, or a ride, a change and a ride, tried over every pair of lines that meet. The trip is drawn in the accent colour over the faded network, the camera frames it, and the cells under the map spell it out ride by ride and stop by stop, with the total minutes. The map button frames the whole network instead. Built from Map, Native Select, Button and Guides. For transit agencies, city guides, campus and event travel pages.
FAQ
Where do the lines come from, and what is fetched?
Each line was traced once along the streets between its stops with OSRM, thinned, and stored in LEG_LINES with the metres of each stretch; a ride the other way reads the same street backwards. Nothing is fetched at run time except the map tiles, and nothing leaves the page. Leeds and its streets are real; Tramhollow, its lines and every minute are invented sample data, not a timetable.
How is the route chosen?
bestTrip first looks for one line that serves both stops. If there is none, it tries every line through the start with every line through the end, at every stop the two share, as a ride, a change and a ride. Fewer changes always win; among equals the quickest does. A ride takes its street metres at a typed speed (trams 20 km/h, buses 15 km/h, stops included) and a change costs three minutes.
What can I do on the map?
Press any stop to make it your destination; the stop you start from stays. The camera frames each new trip, at once under reduced motion, and the map button, pressed, frames the whole network until you pick again. The stops on your trip stay clear while the others fade, and the start, the change and the end are named on the map.
Can I use it without a mouse?
Yes. From and To are native selects with their labels, the swap and map buttons and the zoom buttons work from the keyboard, and the map itself takes the arrow keys and plus and minus once focused. The stops on the map are a pointer shortcut to the To select. A polite message reads the trip (its minutes, its first line and its change) once the choice settles.
How do I use my own network?
Replace STATIONS (a name and a place for each stop), LINES (a letter, tram or bus, and its stops in order) and LEG_LINES (the streets between neighbouring stops, from your GTFS shapes or a routing service). Interchanges, line-end tiles and the route search all follow from those lists; set SPEEDS and CHANGE to your timings.





