Skip to content

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

Sports Facilities Map Block for React

Eight Barcelona sports sites on a live map with a sport filter; each pin shows today's free slots, and the chosen site's hourly grid holds a free slot.

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 people see what is free before they head over, with this sports facilities map for React with Base UI. Hoopfield, a network of sports sites, puts eight sites in real Barcelona neighbourhoods and on two real beaches on a live Map that follows your theme, light or dark: two each for football, swimming, beach volleyball and climbing. A multi-select Toggle Group floating over the map picks the sports and the other pins fade. Each pin is its sport's icon with today's free slots in a bubble, and a full site wears a dashed ring. The band docked under the map lists the sites, the keyboard's way to the same choice as the pins, and holds the chosen site's slot grid for Monday 26 October: one row per hour from 15:00 to 21:00 and one column per pitch, lane, court or wall. A free slot is a button that holds it, a held one releases it, and a taken one is dashed and says Taken. Holding lowers the free count on the pin and in the list, and the line under the grid says what is held here. Built from Map, Toggle Group, Button, Empty and Guides. For sports centres, leisure trusts, clubs and any bookable space.

FAQ

Where do the free and taken slots come from?

Each site's line in SITE_LINES ends with one string per pitch, lane, court or wall, one letter per hour from 15:00: x is taken and . is free. freeOf counts the dots and takes away what you hold, so the pin, the list and the grid always agree. In your app, fill those strings from your booking system for the day shown.

Does holding a slot book it?

No. A hold is local state in this tab: it lowers the free counts and turns the slot into Held, and pressing it again, or Release, gives it back. Nothing is booked, sent or stored, and the line under the grid and a polite message both say so. Wire your own reservation call where hold sets the state.

What is real, and what stays local?

The neighbourhoods and the Bogatell and Barceloneta beaches are real places; Hoopfield, the sites' names and every slot are invented sample data. Nothing is fetched at runtime but the map tiles. "Today" is the fixed AS_OF date, so the block never reads the clock.

How does the sport filter work?

The toggle group can hold any mix of the four sports. Pins of the others fade to a quarter and drop their count, and their sites leave the list, which keeps its height; with no sport picked the list shows an empty state. Picking a faded pin turns its sport back on and opens that site's grid.

Can I use it without a mouse?

Yes. The sports are a toggle group, every site in the list is a button with a pressed state, and every free slot is a button whose name says the unit, the hour and what pressing it does; taken slots are text, so Tab skips them. The zoom buttons work from the keyboard, and the map takes the arrow keys and plus and minus once focused.

How does it look on a phone?

The map comes first with the sports bar over it, wrapping to two rows, then the caption, the list of sites and the slot grid. The grid has an hour column and two to four unit columns, so it fits a 320 pixel screen without scrolling sideways.