shadcn.io is an independent project built on shadcn/ui
On this page5 sections
Installation
Overview
See what a swing would change, with this election results map for React with Base UI. Pollwright, an election night desk, draws Lyon's nine arrondissements at their real borders on a live Map that follows your theme, light or dark, each won by one of three invented lists. The winner is a letter in the arrondissement's badge and a fill weight on the map, A heaviest, B middle and C lightest, never a party colour. A Slider in the desk floating over the map applies a uniform swing from A to B, 0 to 8 points: A loses that many points everywhere and B gains them, so every arrondissement where B overtakes the leader changes hands, drawn with a dashed edge and a dashed ring round its badge. The 73-seat bar redraws with a mark at 37 for a majority, and the line under it names the swing B needs to win one. The nine arrondissements are buttons in the desk; choosing one, there or on the map, outlines it and shows its three shares after the swing, its lead and its turnout. Built from Map, Slider and Guides. For election night desks, newsrooms and civic data tools.
FAQ
What exactly does the swing do?
afterOf takes the swing off A's share and adds it to B's in every arrondissement, leaving C's alone, so the gap between A and B closes by twice the swing. holderOf then gives the arrondissement to the list with the highest share; a tie stays with the night's winner. The same rule would hand B an arrondissement that C won if B came close enough; here C's two are out of reach. The map, the badges, the desk and the seat bar all read these two functions, so they always agree.
How are the seats counted?
Each arrondissement has a typed number of seats, 73 in all, and in this demo the list that comes first in an arrondissement takes all of them. seatsOf adds them up per list, a majority is 37, and B_MAJORITY_AT is the smallest step on the slider at which B reaches it, worked out once from the data.
Where do the borders and results come from, and what stays local?
The arrondissements' borders come from OpenStreetMap, simplified to under 40 points each with their shared edges kept, and are typed into RINGS. The lists, their votes, the turnouts and the seat rule are invented and typed into LINES; nothing here predicts or reports a real vote. The basemap tiles come from CARTO over OpenStreetMap data. Nothing is fetched besides the tiles, and nothing is sent or saved.
Can I use it without a mouse?
Yes. The slider takes the arrow keys, Page Up and Down, Home and End, and reads its value in points; every arrondissement is a button in the desk with its pressed state; the zoom buttons work from the keyboard, and the map takes the arrow keys and plus and minus once focused. The badges and the shapes on the map are a pointer shortcut to the same choice. A polite message gives the seats, the majority and the chosen arrondissement once the slider settles.
Why no party colours?
Colour alone fails readers who can't tell hues apart and clashes with any theme. Here each list is a letter, a badge shape (filled, outlined or muted) and a fill weight in the foreground colour, and a change of hands is a dashed line, so the map reads in every preset, light or dark, and in greyscale print.





