shadcn.io is not affiliated with official shadcn/ui
Tag Cloud Blog Block for React
A foraging blog's tag cloud: fourteen tags in five sizes derived from their post counts, each a toggle that lists its three latest posts in a fixed-height panel beside the cloud.
Installation
Overview
A tag cloud for React with Base UI, written for Thicket, a foraging blog. A start-aligned header sits over a split. At the start, a framed cloud of fourteen tags in five size steps derived from how many posts carry each, with the count after the name; every tag is a toggle. At the end, behind a divider, a panel of fixed height lists the three latest posts for the chosen tag, with a Clear button and a polite line saying how many posts the tag has ("Latest 3 of 4 posts tagged Mapping"). Pick the same tag again, or Clear, to go back. The panel never changes height, so the cloud and the page stay put, and on a phone the results sit under the cloud. Counts, sizes and results all come from the typed list of posts. It's built from Toggle Group, Button and Guides, with CSS for the entrance and the hover. For blogs and journals with many topics and no room for a long menu.
FAQ
How do I add posts and tags?
Edit POSTS at the top of the file, newest first: each post lists its tags by name. The tag list, the counts, the five sizes and the results are all derived, so a new tag is simply a new name on a post. The sizes are chosen by where a tag's count falls between the least and the most used tags.
How are the five sizes chosen?
The counts are spread across five equal steps between the smallest and the largest, and each step has a type size and a weight written out in weightOf. A tag used once is the smallest, the most used is the largest and heaviest. The size is never the only signal: the count follows each name, and a screen reader hears "Safety, 5 posts".
How does it work with a keyboard and a screen reader?
The tags are one single-choice group named "Tags": Tab reaches it, the arrow keys move between tags, and Space or Enter chooses one; choosing the pressed tag again clears it, as does the Clear button. The line above the results is a polite status, so a screen reader hears how many posts the tag has, and the results are a list named for the tag. Each result is one link, its title.
Why is the results panel a fixed height?
So that choosing a tag never moves anything: the panel is as tall as three result rows plus its header whether it shows three posts, one, or the hint to choose a tag. A tag with fewer than three posts leaves empty space under its rows. Titles clamp to two lines to keep rows the same height.
How does it fit on a phone?
The cloud comes first, wrapping to the width of the screen, then the results panel under a hairline. Both together fit in about one and a half screens. Nothing scrolls sideways at 320 pixels.
Related
- Pro
Categories Blog
Topics and indexesA houseplant magazine's category index: seven cells on shared hairlines, each a link with an icon ring, a scope, the latest post, a post count and a bar for its share, derived from the list of posts.
- Pro
Filter Chips Blog
Card gridsA coffee journal's archive with a ruled band of category chips and their counts over eight post cells: choosing a chip removes the other posts, a polite line says how many show, and the wall keeps its height.
- Pro
Search Grid Blog
Card gridsA developer-tools blog behind a search field: a slash shortcut focuses it, typing keeps the posts whose title or summary holds the words and marks them, and six cells draw tiny tool windows as covers.
- Pro
Tag Popover Cards Blog
Card gridsThree post cells on shared hairlines, each with a drawn wood-grain cover and three tag chips; a post with more tags shows a +3 button that opens a popover of the rest as links with counts.
- Pro
Directory Blog
Topics and indexesA map blog's A to Z index as a framed command palette: twenty-four posts grouped by the letter they start with, a filter field, arrow keys, a count and key hints at the foot.
- Pro
Tags FAQ
Topics and filtersA tagged FAQ for a children's book club: a side header with a tag cloud, and questions that carry their own tag buttons, both filtering the same list.