Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Accordion Expandable Reviews Block for React

Twelve 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.

Framework
UI library

Preview

Preview width

Installation

Part of Pro
Pro unlocks the code and one-line install of every Pro button and text effect, plus the MCP for your AI editor.
Have Pro already? Sign in to open it.Opens here as soon as you're Pro.

Overview

An accordion of reviews for React with Base UI, for Ashlarfold, a fictional interior paint. A start-aligned header gives the count and the average (worked out from the twelve typed reviews) and carries an "Expand all" button at its end. The rows run from rail to rail under a rule with + marks. A closed row shows the stars with their number, the title, a one-line excerpt, the reviewer and the date; an open row adds the whole review with its Helpful vote that counts once and, on five of the twelve, the seller's reply in a quiet box. Any number of rows can be open at once, and the header button opens or closes every row. On a phone the row wraps to the stars, the title and the byline. It's built from Accordion, Toggle, Rating, Avatar and Guides.

FAQ

How do I change the reviews and the replies?

Edit REVIEWS at the top of the file. Each entry has a body, a date, a helpful count, an id, the name, a rating, a title and a reply; leave reply empty and the reply box doesn't draw. The seller's replies are typed text, as the block sends nothing, and the "have a reply" count in the header is worked out from them.

How many rows can be open, and what does Expand all do?

Any number. The open rows are held in the block, so Expand all opens all twelve, the label turns into Collapse all, and a polite line says "All 12 reviews are open." Opening or closing a single row afterwards keeps the rest as they were. The Accordion takes multiple and a controlled value.

Are the closed reviews in the page's markup?

Yes. The Accordion takes hiddenUntilFound, so closed reviews stay in the markup as hidden="until-found" and the browser's find in page opens the row that holds a match.

How does it work with a keyboard and a screen reader?

Each row's trigger is a button inside its own h3, so a headings list shows all twelve titles, and it says whether it is expanded. Tab moves from row to row and into an open row's Helpful button; Enter or Space opens and closes a row. This library's accordion does not move between rows with the arrows: use Tab.

How does it fit on a phone?

The trigger wraps to two or three short lines: the stars and their number, the title, then the reviewer and date. The one-line excerpt is dropped until the row opens, and the open review stacks the reviewer, the text, the vote and the reply.

  • Pro

    Compact List Reviews

    Lists and pages

    Twelve 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

    Paginated List Reviews

    Lists and pages

    Twenty-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

    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.

  • Pro

    Reply Thread Reviews

    Votes and replies

    One three-star dishwasher review with its conversation in a single framed window: the seller's reply, the buyer's follow-up and the seller again under depth rails, and a real reply form with a live character count that appends your reply to the end.

  • Pro

    Helpful Votes Reviews

    Votes and replies

    The best favourable and the best critical review of a water filter jug side by side, each with a Helpful vote and a worked-out 'n of m found this helpful', above the other reviews in ruled rows with a most-helpful or newest order.

  • Pro

    Detailed Card Reviews

    Cards and walls

    One review with everything it can carry in a card in card: the reviewer and purchase facts, five criteria scores, pros and cons, three drawn pictures, a Helpful vote and the seller's reply.