shadcn.io is not affiliated with official shadcn/ui
Search Testimonials Block for React
A search box in the header row that filters eight customer quotes as you type and marks the matched words, with a result count, Escape to clear and an empty state, in a band of hairline-ruled rows.
Installation
Overview
Customer proof the visitor can search, for React with Base UI, about a fictional component library called Hollis. A compact header holds the headline and a sentence, with a search box at its end (a magnifying glass and, once you type, a clear button). Below, one band with + marks on its corners holds eight quotes as rows ruled apart by hairlines: who said it at the start, the quote at the end. As you type, the rows keep only the quotes that contain your words, and the matches are marked inside the text with a light tint of the text colour: each one is underlined at once and then filled in, one after the other, in reading order. A line at the top of the band counts the results ("2 results for “types”"), Escape clears the box, and a search that finds nothing shows an empty state with a Clear search button. Case and accents are ignored, so "resume" finds "Résumé". On a phone the first four quotes show behind an "All 8 quotes" button, and a search skips it and shows every match. It's built from Input Group, Search Highlight Text, Empty, Avatar, Button and Guides, with your theme's tokens only. For pages with enough quotes that a visitor would rather look than scroll.
FAQ
How do I change the quotes?
Edit PEOPLE at the top of the file: each person has a quote, name, role, company and initials. The search reads only the quote text, which is also the text that gets marked, so a result always shows why it matched. Add as many quotes as you like; the band reserves room for all of them.
What does the search match?
The text you type, anywhere in a quote, ignoring case and accents. A phrase matches as a phrase, so "dark mode" finds only quotes that have those two words together. It is a plain text search, not a pattern: characters like a dot or a bracket just match themselves. For fuzzy matching, swap the matches helper and give the highlight your own matcher.
What does a screen reader hear?
The box is a search landmark with a label, and the matched words are real mark elements. The result count is read out by a hidden polite status line a moment after you stop typing, so it isn't repeated on every keystroke; the visible count beside it is hidden from screen readers so it isn't read twice. Quotes that do not match are taken out of the page for screen readers as well as for the eye, and the "All 8 quotes" button reports whether the rest are shown.
How do I clear the search with a keyboard?
Press Escape in the box, or Tab to the Clear button that appears beside it and press Enter. Either one empties the box and keeps focus there. The empty state's Clear search button does the same.
Why doesn't the page jump as the list shrinks?
An unseen copy of all eight rows sits in the same grid cell as the live list, so the band keeps its full height while the quotes you searched out leave. The copy is hidden from screen readers and can't take focus. On a phone the copy follows the "All 8 quotes" button, so a search with more matches than the four shown by default grows the list; that is the one deliberate shift.
Related
- Pro
Filterable Testimonials
Filter and searchRole chips with live counts filter a wall of eight customer quotes, with a status line, a clear button and an empty state. A hairline band holds the controls and the cells' lines overshoot their corners.
- Pro
Tag Filter Testimonials
Filter and searchA wall of nine customer quotes for a component kit in hairline cells, each ending in two topic tags that are buttons: pick one to filter the wall and get a removable chip.
- Pro
Snippet Testimonials
Chats and postsCustomer quotes for a component kit, set out like search results: a result count on a ruled band, then six results in two columns sharing their hairlines, each with a breadcrumb, a linked outcome headline and an excerpt with the matching terms in bold.
- Pro
Split Search Bar Hero
Interactive demosA split hero whose call to action is a large search field with a Shine Button, popular searches, and, across a solid divider, a results panel that filters as you type.
- Pro
Centered Search with Product Card Grid Hero
Interactive demosA centered showcase hero for a marketplace: a search form with the Shine Button and category pills that really filter a shelf of eight product cards in hairline cells.
- Pro
Industry Tabs Testimonials
Filter and searchIcon tabs in the header row that switch customer quotes by industry: four sectors, each a panel of three cells (the typical rollout time and two quotes) above a band with a Shine Button.