Skip to content

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

Community Events Map Block for React

A week of Leith's community events on a live map, with a row of cards whose Going toggles take a spot and fill each marker's ring as the event fills.

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

Let neighbours say they're coming with this community events map for React with Base UI. Hollybush, a neighbourhood noticeboard, puts the week's eight events in Leith, Edinburgh, on a live Map that follows your theme, light or dark: a seed swap on Leith Links, a talk at the library, a litter pick at Newhaven Harbour, each at its real place. Under the map the cards, in date order (a row on a phone, a grid of four from tablet width), give each event's day, kind, place and spots free, with a Toggle that says you're going and takes one spot. The spots free come from the capacity, the others already going and you; the bar in the card and the ring round the marker fill as the event fills, a tick on the marker says you're going, and a full event you aren't going to disables its toggle, which reads "Full". The kind is an icon and a word: a basket for a market, a cap for a class, a leaf for a clean-up, a microphone for a talk. Choosing a card flies the map to the event; on a phone, choosing a marker also scrolls its card into view inside the row, never the page. Built from Map, Toggle, Button and Guides. For residents' associations, libraries, village halls and any local calendar.

FAQ

How are the spots free worked out?

freeOf takes the event's capacity, subtracts the people already going (taken, typed in LINES) and one more when you're going. shareOf turns the same numbers into a share out of 100, which sets both the card's bar and the marker's ring, a circle with pathLength 100 so its dash is the percentage. Nothing is stored twice.

Is anything told by colour alone?

No. The kind is an icon and a word, how full it is is a length and a sentence ("27 of 50 spots free", "Full"), going is a tick on the marker and a pressed toggle with a check, and the chosen event is inverted on the map with its name under it and a rule along its card's top.

How do the map and the cards keep in step?

The block keeps the chosen event and one camera aim. Choosing a card flies the map to the event through MapCamera; choosing a marker does the same and, where the cards are a row (on a phone), scrolls it sideways with scrollBy, so the card comes to the middle without moving the page, instantly under reduced motion. On a phone the camera stands a zoom level further out, so the streets round the event stay in view. The map button frames every event again.

Can I use it without a mouse?

Yes. Each card has a Going toggle named after its event ("Going: Harbour litter pick") and a button that finds the event on the map; Tab walks along the cards and scrolls the row as it goes. The markers are a pointer shortcut to the same choice. The count of events you're going to sits in a polite status line above the row.

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

Going is local state that resets on reload: no spot is held and nobody is told, and the status line says so. The places are real; the events, dates and counts are invented, and only the map tiles load, from CARTO over OpenStreetMap. In your app call your RSVP endpoint from changeGoing and take the new count from the server.

How does it look on a phone?

The map comes first, then the caption, then the week's row of cards, about one and a quarter wide, snapping as you swipe; from tablet width the eight cards become a grid of four. Scrolling the page over the map scrolls the page; two fingers move the map.