shadcn.io is not affiliated with official shadcn/ui
Score Bar Leaderboard Stats Block for React
Seven quiz players in a band that runs from rail to rail, each row a name, a context line, the points and a thin bar measured against the leader's score.
Installation
Overview
A leaderboard with score bars for React with Base UI. A start-aligned header names the leader and the gap to second place, then a band of seven players runs from rail to rail and ends the block. A row is two lines and a bar: the rank in mono, the player with a line under the name ("118 quizzes, 84% correct"), the points at the end with how far they are from the leader ("86% of the leader"), and, under both, a thin bar. Every bar is measured against the leader's score, so the leader's bar fills the row and the rest show the gap; the leader's is solid and the others a weight lighter, never a different colour. The bars grow in once from the start, in a short stagger, and sit still under reduced motion. Ranks, shares and bar widths are worked out from the typed scores when the module loads. For a ranking where the distance between players matters as much as the order.
FAQ
How do I change the players and the scores?
Edit PLAYERS: a name, the points, the number of quizzes and the share of answers correct (correct). The rows are sorted and ranked when the module loads; the bar width is the player's points over the highest score, the share text and the headline gap come from the same numbers. To rank on another measure, change points and the unit words in the row.
Why are the bars measured against the leader and not against a total?
A share of the total would make every bar short in a long list and hide the gap that matters. Against the leader, the first bar always fills the row, and a bar's length is the answer to "how close is this player?", which is what a leaderboard asks. The text beside each bar says the same ("86% of the leader"), so the bars are decoration.
Why is the leader's bar solid and the others lighter?
Weight is the only difference between the bars, because colour can't be relied on across presets and for everyone. The leader's bar is the theme's foreground; the others are a mix of the foreground and the background, which keeps contrast against the light track in every theme.
Is it accessible?
Yes. The list is ordered and named ("Points this month"); every row says its rank, the player, the context line, the points and the share of the leader in text, and the bars are hidden from assistive technology because they add nothing the text doesn't say. Points and shares sit in bdi elements for right-to-left pages. With reduced motion the bars are drawn at full length at once.
Related
- Pro
Horizontal Bar Chart Card Stats
Bar and columnNine ranked survey answers where each row is its own bar: a quiet fill from the start behind the label, the share and the count at the end, and the leading row a little stronger.
- Pro
Compact List Leaderboard Stats
LeaderboardsA league table for a pub-quiz league in a split: the header and three season facts at the start, and all twelve teams in dense rows, two columns of six, at the end.
- Pro
Ranked List Leaderboard Stats
LeaderboardsA six-row ranking in a hairline frame with a Week and Month switch that re-ranks the table: a large numeral and a quiet tint for the leader, and points that roll to their new numbers.
- Pro
Progress Bar List Stats
Goals and progressSix launch milestones in one hairline frame, each with its owner and due week, its count against the target, the percentage and a Progress bar, under a headline that counts the milestones done.
- Pro
Bullet Chart Stats
Bar and columnFour bullet graphs for department KPIs, each with three shaded ranges, a bar for the result, a tall tick for the target, a labelled scale and a verdict with a glyph and words.
- Pro
Stacked Percentage Bar Stats
Parts of a wholeOne thick bar of a consultancy's week split into four segments at four weights with labels inside the wide ones, and a band of four legend cells under it; pointing at or focusing a cell brackets its segment.