shadcn.io is not affiliated with official shadcn/ui
Pinned Featured Reviews Block for React
Three 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.
Installation
Overview
Pinned featured reviews for React with Base UI, for the Holmfold Stack 5, a fictional bookshelf. A header with the title and one sentence sits over a split behind a divider. At the start, three numbered slots as an ordered list: a pinned review shows its number, stars, title and reviewer with Up, Down and Unpin buttons, and an empty slot says so. At the end, all seven reviews as ruled rows, each with a Pin button. A review that is pinned leaves a quiet line ("Pinned in slot 2") in its row, so the list never moves. When all three slots are full the Pin buttons say "Slots full" and a Select above the list asks which slot the next pin replaces; after you choose one, every row's button reads "Replace slot 2". A polite line under the slots says each change, and focus follows the button you used. Nothing is saved: the order lives on the page until it reloads. Stars are the read-only Rating in your theme's text colour, with the value in words beside them. All seven reviews are typed at the top of the file. It's built from Button, Select, Badge, Rating, Avatar and Guides.
FAQ
How do I use my own reviews and my own limit?
Replace REVIEWS at the top of the file, newest first (each has an id, name, rating, ISO date, title, body and verified), and set START to the ids that begin pinned. The limit is SLOT_COUNT; the slot numbers and the Select's options come from SLOT_NUMBERS, so change both together for four slots.
Is the pinned order saved anywhere?
No. It is local state: pinning, moving and unpinning change the lists and a polite line says what changed, but nothing is sent and a reload starts again from START. To keep it, send the pins array to your own endpoint from the handlers.
What happens when all three slots are full?
The Pin buttons wait ("Slots full") and a Select replaces the "slots free" note above the list. Choose Slot 1, 2 or 3 and every row's button reads "Replace slot N"; press one and that review takes the slot, while the review it replaced goes back into the list. Unpinning, moving or choosing a slot again clears or changes the choice.
Where does focus go after a move?
To the button you just used, or its neighbour when that button has reached an end and is disabled: after Unpin, to that review's Pin button in the list; after a Pin, to its Unpin button in the slots. Every button is a real button with a name that includes the review's title, so a screen reader hears what it acts on.
Related
- Pro
Featured Carousel Reviews
Cards and wallsA framed carousel of five editor's picks for a desk chair, each chosen by a rule worked out from ten typed reviews: most helpful, most detailed, best critical, newest verified and longest owned.
- 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
Pin a Quote Testimonials
Expand, flip, pinFour quote rows in a ruled list with Pin toggles: the pinned quote moves up into a large featured card, a raised panel in a tinted shell with + marks, split from the list by a solid divider, under a compact header with a Shine Button.
- Pro
Helpful Votes Reviews
Votes and repliesThe 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
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
Range Slider Testimonial Reviews
Cards and wallsA two-thumb star range picks which of a camera bag's 13 reviews you read, one full review at a time, with Previous and Next buttons, the arrow keys and a Review 2 of 10 counter.