Skip to content

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

Forest Coverage Map Block for React

The forest round Cujubim, Brazil, as a canopy raster on a live map, with a slider that swipes from 2005 to 2025, loss and regrowth, and four projects.

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 what twenty years of roads took from a forest, with this forest coverage map for React with Base UI. Canopymark, a conservation group, maps the canopy round Cujubim, in Rondônia, Brazil, as a raster of 60 by 30 cells on a live Map that follows your theme, light or dark, each cell a dot sized and coloured by one of five classes, from none for cleared ground to the largest for dense canopy, in the theme's chart colours. A Slider in the band under the map swipes between the years: the cells west of the line show 2005, the rest 2025, and a hairline with two year tags marks the line on the map. Each cell's class was baked from its distance to the nearest real road, so the clearings follow the fishbone of side roads you can see through them. Beside the slider, forest cover in each year, the share of 2005's forest lost and the share regrown are counted from the two rasters themselves, with the hectares. Four reforestation projects are numbered pins with dashed outlines, and cells under the band that fly the camera to each. Built from Map, Slider, Button and Guides. For conservation groups, land agencies and carbon accounting.

FAQ

How are loss and regrowth counted?

Cell by cell, from the two rasters typed in the file. A cell is forest from open woodland up (FOREST_FROM); lost is forest in 2005 and not in 2025, regrown the reverse, and both are shares of the 2005 forest. The hectares multiply the cells by each cell's area at that latitude, so the figures always match the drawing.

Where does the raster come from?

It was baked once from OpenStreetMap: each cell's class follows its distance to the nearest road, with older roads near the main highways cleared first and a seeded wobble, and the four project areas regrown. It is typed into the file as 30 rows of 60 digits for each year, drawn as 1,800 dots; nothing is fetched apart from the map tiles. The roads are real; the classes are sample data, not satellite imagery.

How does the swipe work?

The slider sets which column the years split at: every cell west of it reads its 2005 class and every cell from it east its 2025 class, in one paint expression, so nothing is redrawn but each dot's size and colour. The line and its year tags move with it and stay on the map as you pan and zoom.

Can I use it without a mouse?

Yes. The slider takes the arrow keys, Home and End, and speaks how much of the region shows 2005; every project cell is a button that flies the map to it, and the zoom and frame buttons work from the keyboard. The map itself takes the arrow keys and plus and minus once focused, and a polite message repeats the figures once the slider settles.

What stays local in the demo, and how do I wire it up?

All of it. The rasters, the classes and the four projects are typed into the file; Canopymark and its projects are invented. In your app classify your imagery into the five classes for each year, keep the two rows of digits per year or a raster source, and keep the counting, which reads only those classes.

How does it look on a phone?

The map keeps its full width with the year tags on the line, the legend wraps, the slider sits under it with the four figures in two rows, and the project cells follow two by two. Moving the slider never changes the height of the block.