Skip to content

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

Maritime Traffic Map Block for React

Ten vessels approaching Rotterdam on a live map, with heading lines, a type filter, an inbound ship's way to its berth with an ETA, and a Follow switch.

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

Follow a ship into harbour, with this maritime traffic map for React with Base UI. Bellbuoy, a harbour authority, shows ten vessels in the approach to Rotterdam on a live Map that follows your theme, at their places in the North Sea, the Maasgeul fairway and the Maasmond at 08:40 UTC. Each vessel is a hull that points along its heading, filled for cargo, larger for a tanker, hollow for a ferry and small for a tug, with a line ahead of it to where it will be in ten minutes; the fairway is a dashed line and two dashed boxes are anchorages. A floating card holds a Toggle Group of vessel types, the list of all ten and the chosen vessel's speed, heading and ETA, and docks under the map on a phone. Choosing an inbound vessel, in the list or on the map, draws its way in along the fairway to its berth in the primary colour, and its ETA is that way's length over its speed; the Switch named Follow brings the camera in close on the chosen vessel and keeps it there as you choose another. Built from Map, Toggle Group, Switch, Label and Guides. For harbour authorities, shipping agents and port apps.

FAQ

How is the ETA worked out?

For an inbound vessel under way, pathOf builds its way in: from where it is, along the fairway points still ahead of it (or the ferry lane for a ferry), then through the port's basins to its berth. lengthOf adds up that path in metres, which over 1,852 gives nautical miles; divided by the speed in knots and added to the snapshot's 08:40 it gives the ETA. Outbound vessels, ships at anchor and assisting tugs say so instead. It is a sketch, not a navigation aid.

What does Follow do?

The block keeps one aim for the camera: the whole approach, or, with Follow on, the chosen vessel at a closer zoom. Choosing another vessel while Follow is on flies there, quickly or not at all under reduced motion. From tablet width up the camera frames the water to the side of the card, so no vessel hides under it.

What happens when I hide a vessel type?

Its hulls fade on the map and their heading lines go, and its rows stay in the list marked Hidden, so the list never changes length. The chosen vessel stays shown whatever the filter, and choosing a hidden one shows its type again.

Can I use it without a mouse?

Yes. The types are a toggle group with the arrow keys, each vessel in the list is a button with a pressed state, and Follow is a labelled switch. The hulls on the map are a pointer shortcut to the same choice, and the zoom buttons and the map's own keys work once focused. A polite message speaks the chosen vessel, its speed, heading and ETA.

How does it look on a phone?

The map comes first, then the card docked under it with the type toggles, all ten vessels and the chosen one's figures, then the caption. The anchorage names give way to the vessels on the small map; the caption still names them. Two fingers move and zoom the map, and one finger scrolls the page.

What stays local, and how do I feed it real positions?

All of it: the positions are one invented snapshot, nothing moves and nothing is received. The tiles are CARTO's basemaps over OpenStreetMap data, drawn by MapLibre GL. In your app, fill LINES from your AIS or vessel-traffic feed on a timer, keep FAIRWAY and BERTHS for your port, and keep pathOf and minutesIn for the ETA.