Skip to content

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

Coral Reefs Map Block for React

Nine Indo-Pacific reefs on a live map with a warming toggle (Today to +3 °C) that thickens each reef's risk ring, filter cells and a fly-to list.

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 which reefs bleach as the sea warms, with this coral reefs map for React with Base UI. Atollwatch, a reef monitoring group, scores nine reefs from the Red Sea to the Coral Sea, each at its real place on a live Map that follows your theme, light or dark. A Toggle Group floating over the map picks a scenario (Today, +1, +2 or +3 degrees) and each reef's bleaching risk is set from its typed base and its sensitivity to each degree. Risk is told three ways: a ring of one, three or five pixels round the marker, the number out of 100 inside it, and the word (High, Medium, Low) in the list. Choosing a reef, on the map or in the list, flies the camera there and fills its card with the risk and the coral and fish species counts; the globe button frames all nine again. Three cells under the map count the reefs at each level ("4 of 9") and filter the list and the markers; the list holds its height and shows an empty state when a level has none. Built from Map, Toggle Group, Button, Empty and Guides. For marine charities, reef managers and climate dashboards.

FAQ

How is the risk worked out?

riskOf adds the reef's sensitivity for every degree of warming to its base index and stops at 100. High is 70 and over, Medium 40 to 69, Low under 40. The reefs and their places are real; the bases, sensitivities and species counts in LINES are invented for this demo.

How does the map fly to a reef?

The block keeps one aim: every reef (WORLD, the corners of their places) or the chosen one. MapCamera frames the aim when the map starts and flies to each new one, quickly or not at all when reduced motion is on. Pan and zoom freely in between; the globe button aims at every reef again.

How do the filter cells work?

Each of the three cells is a button with a pressed state: press one to show only the reefs at that level, press it again to clear. Reefs outside the filter shrink to small hollow dots on the map. The list keeps a hidden copy of all nine rows so its height never changes, and the empty state is reachable, for instance High at Today.

Can I use it without a mouse?

Yes. The scenarios are a toggle group, the filters and every reef in the list are buttons, and the zoom buttons work from the keyboard; the map itself takes the arrow keys and plus and minus once focused. The markers are a pointer shortcut to the same choice as the list. A polite message gives the counts and the chosen reef once the choice settles.

Where do the map tiles come from?

From CARTO's free basemaps over OpenStreetMap data, loaded by MapLibre GL, the engine under the Map component; their credit stays in the map's corner. Scrolling the page over the map scrolls the page: hold Ctrl or ⌘ to zoom, or use two fingers on a phone.

How does it look on a phone?

The map comes first with the scenario bar over it, then the reef list, the reef's card and the three filter cells in one row at the end. The block's height is the same for every scenario and filter.