Skip to content

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

Shipping Lanes Map Block for React

Eight freight lanes through the Strait of Malacca on a live map, each stretch as wide as its weekly cargo, with a cargo toggle and port cards that sum it.

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

Show where the freight moves, with this shipping lanes map for React with Base UI. Cargomoor, a freight analytics tool, follows eight lanes between six real ports, Singapore, Tanjung Pelepas, Port Klang, Penang, Belawan and Dumai, along the channel of the Strait of Malacca on a live Map that follows your theme. The map draws the channel stretch by stretch, each as wide as all the cargo that passes along it in a week, so the busy southern reaches swell and the spurs to small ports stay thin. A Toggle Group floating over the map swaps the cargo between containers, bulk and liquid, and every width with it. Under the map, a row of port cards in step with the markers gives each port's cargo in and out, its share of all traffic as a bar and a number, and its lanes with their volumes. Choosing a port, on its card or its marker, draws its own lanes over the rest in the primary colour, as wide as its part of each stretch, and frames them; the expand button frames the whole strait again. Built from Map, Toggle Group, Button and Guides. For freight dashboards, port authorities and logistics tools.

FAQ

How is a stretch's width set?

stretchVolume adds up the chosen cargo of every lane that runs along the stretch, in thousand tonnes a week, and the line's width rises from a hairline to 12 pixels at the busiest stretch of any cargo. One scale serves all three cargoes, so switching from containers to bulk visibly thins the channel. The chosen port's layer uses the same scale with only its own lanes, so the primary band shows its part of each stretch.

What does the share of all traffic mean?

A port's cargo in plus out, over twice the total of all eight lanes, because every lane counts at both of its ends. The six shares therefore add up to about 100, and the card shows the share for the chosen cargo, as a bar and as a number.

Can I use it without a mouse?

Yes. The cargo is a toggle group with the arrow keys, each port card's name is a button with a pressed state (press it again to see the whole strait), and the zoom and expand buttons work from the keyboard. The markers are a pointer shortcut to the same choice, and a polite message speaks the port's cargo in and out and its share.

How does it look on a phone?

The map comes first with the cargo bar over it and the controls in the empty top corner, then the caption, then the port cards in a row you swipe through, each snapping into place. Every card keeps room for five lanes, so the row never changes height as the cargo changes.

How do I use my own ports and lanes?

Edit PORT_LINES (id, name, country, longitude, latitude and which side its label sits), STRETCHES (pieces of the channel, typed through the water) and LANE_LINES (id, from, to, the three volumes and the stretches the lane follows). The widths, sums, shares and cards are computed from them.

What stays local, and where does the map come from?

Everything: the ports and the channel are real places, but Cargomoor and every volume are invented and nothing is read from a manifest. The tiles are CARTO's basemaps over OpenStreetMap data, drawn by MapLibre GL, with their credit in the corner. In your app, aggregate weekly volumes per lane and cargo from your tracking data and keep inboundOf, outboundOf and shareOf as the display logic.