shadcn.io is not affiliated with official shadcn/ui
Masonry Layout Reviews Block for React
Twelve reviews of pruning shears as cards of every length in CSS columns, with a star filter, an order switch, a polite count and a Helpful vote on each card.
Installation
Overview
A masonry of reviews for React with Base UI, for the Furrowmill Bypass Pruners, a fictional garden tool. A start-aligned header gives the count and the average (worked out from the twelve typed reviews), two toggle groups filter by stars (All, 5 stars, 4 stars, 3 and below) and set the order (Newest, Most helpful), and a polite line counts what shows. The cards sit in CSS columns, three across on a desktop, two on a tablet and one on a phone, read down each column. Each card is a full review with its own overshooting lines: the stars with their value in words, the title, the text, the reviewer with a verified mark, the date and a Helpful vote that counts once. An unseen copy of every card in both orders holds the height, so the page never moves. A phone masks the list at 520 pixels behind a "Show all reviews" button. It's built from Toggle Group, Toggle, Rating, Avatar and Guides.
FAQ
Which way do the cards read?
Down each column, then across: the browser balances CSS columns by height, so the newest review is at the top of the first column and the next ones follow beneath it. Each card is kept whole with break-inside-avoid. Reordering or filtering reflows the columns, which is why the cards are keyed by review.
Why doesn't the page move when I filter?
An unseen copy of all twelve cards, in both orders, shares the grid cell with the live columns. The cell keeps the height of the taller copy, so a filter that shows fewer cards leaves empty space under them rather than pulling the page up. Cards moving inside that fixed space are expected.
How do the two groups behave?
Each is a single choice that cannot be empty: pressing the chosen item again does nothing. The polite line says the result in words, such as "Showing 4 of 12 reviews: 3 and below, most helpful". Edit STAR_CHOICES and ORDER_CHOICES to change the options.
Related
- Pro
Infinite Scroll Reviews
Lists and pagesTwenty reviews of a podcast app ten at a time in a fixed-height scroll region that appends five more at its end, with a Load more button, placeholder rows and a polite count.
- Pro
Paginated List Reviews
Lists and pagesTwenty-four reviews of a cookbook five to a page, with a page-size Select, the catalog pagination with ellipsis and a polite 'Showing 6 to 10 of 24'.
- Pro
Snippet Cards Reviews
Cards and wallsEight review snippet cards on shared hairlines for a yoga mat: each leads with its most helpful sentence, and a Sheet opens the whole review with Previous and Next buttons and a polite counter.
- Pro
Sized Mosaic Wall Reviews
Cards and wallsA wall of twenty-four bicycle light reviews as a mosaic whose tile size follows helpful votes, length or nothing, behind a Show all button.
- Pro
Filter Sort Bar Reviews
Filter and searchA toolbar band for rain-jacket reviews: a rating Select, a Verified toggle, a date Popover and a sort Select, a live count with removable chips, and the matching reviews as ruled rows.
- Pro
Rating Breakdown Reviews
Score summariesA review summary for a carry-on suitcase whose star rows filter the reviews: the average, the count, the share that would recommend it and a five-row distribution, beside the four most helpful reviews with a Helpful vote each.