Block 246 of 297
Leaderboard
A ranked list sorted highest first, with proportional bars, top-three emphasis and an optional top-N limit.
- Puck key
- LeaderboardBlock
- Export
- leaderboardBlock
- React component
- <Leaderboard />
- Path
- components/puck/leaderboard-block.tsx
- Dependencies
- None
- License
- MIT
About this block
When to use it, how to write for it, and what to change in the code.
What it's for
A ranked list that sorts entries highest first, draws a proportional bar under each and emphasizes the top three. Ties share a rank. You can cap how many rows show, with a "Showing top 5 of 7" note when entries are hidden. Entry values are plain text fields, so they can be bound row by row to a P1 data source.
- Volunteer hours or fundraising totals by team
- Top branches, schools or neighborhoods for a participation challenge
- Most-visited pages or most-borrowed titles in a report
Writing the content
- Enter Value as a number; it is parsed and reformatted, and sorting happens automatically, so entry order only breaks ties.
- Use Value prefix for currency and Value suffix for units like hrs or %.
- Set Show top to a number like 5 to keep the card compact. Entries accept up to 50.
- Detail is an optional second line, like "38 volunteers"; long names and details truncate to one line, with the full name in a tooltip.
Accessibility
- Entries are an ordered list labeled by the title, and each rank number carries a hidden "Rank" prefix.
- The bars are aria-hidden because every value is also printed as text beside the name.
- The title can be set to H2, H3, H4 or plain text to fit the page outline (WCAG 1.3.1).
Customizing the code
- Top-three bars use bg-indigo-600 and the rest bg-indigo-300; change both to rebrand.
- The number of emphasized ranks is set by rank <= 3 in the render function.
Editor fields
What content editors see in the P1 sidebar when they select this block.
- Titletext
- Heading levelselect
- Period or subtitletext
- Entriesarray
- Value prefixtext
- Value suffixtext
- Show toptext
- Footnotetext