shadcn.io is not affiliated with official shadcn/ui
Tabbed Sections Reviews Block for React
Eighteen reviews of a sewing machine sorted into four tabs, Most recent, Most helpful, Critical and Verified, each with its derived count and three reviews.
Installation
Overview
Tabbed review sections for React with Base UI, for Bobbinmill, a fictional sewing machine. A centred header gives the count and the average (worked out from the eighteen typed reviews), and a band of line tabs under a rule with + marks offers four groups: Most recent, Most helpful, Critical (one and two stars) and Verified purchases. Each tab carries its count, derived from the reviews, and its panel opens with a line saying which three it shows ("3 of the 4 reviews rated 1 or 2 stars, newest first") above three ruled review rows with the reviewer, the stars, the title and the text. Every panel is drawn once more, unseen, in the same cell, so switching tabs never moves the page. On a phone the tab list scrolls sideways. It's built from Tabs, Badge, Rating, Avatar and Guides.
FAQ
How do I change the tabs?
Each group is a typed list at the top of the file: RECENT, HELPFUL, CRITICAL and VERIFIED are built from REVIEWS with a sort or a filter, and TABS gives each a label, a count, a note and the three rows shown (SHOWN). Add a tab by adding an entry to TABS; the trigger, the count and the panel come from it. The "With photos" tab of other review lists is left out, since no review here carries a photo.
Where do the counts come from?
From the length of each group: all 18 reviews for the first two tabs, the reviews rated 1 or 2 stars for Critical, and the verified purchases for the last. Tab names include the count for screen readers ("Critical 4 reviews").
Why doesn't the page move when I switch tabs?
All four panels are drawn together, unseen, in the same grid cell, and the live panel sits on top of them, so the cell keeps the height of the tallest panel. The unseen copies are hidden from assistive technology and the keyboard.
Related
- 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
Accordion Expandable Reviews
Lists and pagesTwelve reviews of an interior paint as accordion rows: stars, title, excerpt and byline when closed; the whole review, a Helpful vote and the seller's reply when open.
- 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
Compact List Reviews
Lists and pagesTwelve one-line reviews of a notes app as a real table with sortable column heads, a Select that mirrors the sort, and nothing to open.
- Pro
Pinned Featured Reviews
Merchant toolsThree numbered pin slots for a bookshelf's reviews: pin from a list, move a pin up or down, unpin it, or replace a full slot through a Select.
- 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.