shadcn.io is not affiliated with official shadcn/ui
Infinite Scroll Reviews Block for React
Twenty 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.
Installation
Overview
An infinite scroll of reviews for React with Base UI, for Voleline, a fictional podcast app. A compact header leads into a band split by a divider: at the start the score summary of all twenty typed reviews (the average with half-star Rating, the share who rated it 4 or 5 and five distribution rows), at the end a fixed-height scroll region with a polite "Showing 10 of 20 reviews" above it. Reaching the end of the region, or pressing "Load more reviews", shows two placeholder rows for a moment and appends five more; the page never moves. After the last batch a note says that is all of them. On a phone the summary sits on top and the region is 420 pixels tall. It's built from Rating, Skeleton, Button, Avatar and Guides.
FAQ
How do I connect it to a real API?
Replace the 700 millisecond timer in the effect with a request for the next BATCH reviews and append them to the list; shown, the status line, the button and the end note all follow from the array's length. The block sends nothing and holds no real data, and the summary counts the whole typed set, so with an API you would pass the totals in.
How does it work with a keyboard and a screen reader?
The scroll region is a named, focusable section: Tab reaches it and the arrow keys, Page Down and End scroll it, and reaching its end loads more. "Load more reviews" is a real button at the end of the list; after it adds five, focus moves to the first new review, which is scrolled to the top of the region. The status line announces "Loading 5 more reviews" and then the new count.
Why a plain scroll region and not the catalog ScrollArea?
The scroll position has to be read and set, and the catalog ScrollArea wraps its content in a different viewport on each library. A native overflow-y-auto section behaves the same on all four, scrolls with touch momentum and overscroll-contain keeps it from dragging the page.
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
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
Masonry Layout Reviews
Cards and wallsTwelve 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.
- Pro
Timeline Feed Reviews
Lists and pagesTwelve reviews of a smart thermostat on a month-by-month timeline with each month's derived average and count, review cards on shared hairlines and a firmware filter.
- 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.
- Pro
Search Reviews
Filter and searchA search-first review section for a ceramic pot: a large field with suggestions mined from the reviews, per-star result chips that follow the query, a best-match or newest order, and results with every match marked.