shadcn.io is not affiliated with official shadcn/ui
Category Counts Awards Block for React
Nine count tiles on shared hairlines for a sports-league manager: a drawn category glyph, the count in large type, its share of all awards and a bar scaled to the largest, with the largest outlined.
Installation
Overview
A category tally for React with Base UI. A short header and the programme's years sit above a band of nine tiles that share their hairlines, three across on a wide screen and two across on a phone, ending the block. Each tile has a small drawn glyph for its category, the category as a heading, the number of awards it won in large type, its share of all the awards ("8 of 40 awards, 20%") and a bar whose length is its count over the largest count. The category with the most awards is outlined and says so in words. There's no filtering and nothing moves: it's a tally to read. The percentages use largest remainder, so the nine always add to 100. It's built from Guides, drawn SVG glyphs and your theme's tokens. The Glenwell Awards and the wins are made up for the example.
FAQ
How do I change the wins?
Edit CATEGORIES at the top of the file. Each category has an id, a name, a glyph and years: one number for each award it won, each a fixed year. The counts, the total in the header, the shares, the bars and the outlined tile are all counted from those lists. A category with one more win just needs one more year in its list.
Why do the percentages always add to 100?
They use the largest-remainder method. Each share is rounded down first, then the points still missing go to the categories whose shares lost the most in rounding, the larger count first on a tie. A plain Math.round on each tile can add to 99 or 101; this can't. The bar is a different measure: it's the count over the largest count, so the busiest category's bar is full.
How do I draw a glyph for another category?
GLYPHS holds each glyph as a few stroked paths in a 24 by 24 box. Add a key to the Glyph type and a list of paths, then give a category that glyph. They're drawn in your theme's foreground and hidden from assistive technology: the category's name is the label.
What if I have a different number of categories?
The grid is three columns from sm, so a multiple of three fills every row (six or twelve), and two columns on a phone, where an odd last tile takes the full row. For another count, adjust the columns in the list's class; the tiles share a single hairline, so no cell is left showing the border colour.
How do screen readers read a tile?
The tiles are a list named "Awards by category". Each opens with the category as a heading, then the count, then the base and share written out ("8 of 40 awards, 20%"). The glyph and the bar are drawings hidden from assistive technology and carry nothing the text doesn't. Counts sit in bdi elements so they keep their order in a right-to-left layout.
Related
- Pro
Category Grid Awards
Cards and gridsSixteen awards sorted into six categories on a 3 by 2 hairline grid: a drawn glyph, a derived count and the two newest awards named in each cell, the largest category outlined.
- Pro
Total Tally Awards
Lists and tablesA scoreboard table for an accounting app: years down the side, the three tiers (grand prize, winner, finalist) and a total across, with column totals in the foot row, all counted from one list of entries.
- Pro
Medal Count Awards
Rankings and scoresAn Olympic-style medals table for a league-tables service: seven product lines ranked by gold, then silver, with drawn medal heads, a total, a stated ranking rule and a top-line callout.
- Pro
Win Percentage Awards
Charts and figuresA ten by ten waffle of nominations for a sales-analytics tool: won squares filled, shortlisted outlined, the rest faint, with the share won, a count with its base, and a legend, all derived from the editions.
- Pro
Dense Badge Wall Awards
Badges and sealsA wall of twelve drawn award badges on shared hairlines, four across, with a tally counted from the list and a show-all button on phones.
- Pro
Distribution Bar Filter Awards
Charts and figuresOne 100% bar split by award category above eight count pills; pressing a pill emphasises its segments and filters the list below.