shadcn.io is not affiliated with official shadcn/ui
Search Results Notification Block for React
A notification search in three bands: a search field with a slash key, type chips whose counts follow the query, and results with every match marked and an empty state that names the query.
Installation
Overview
Let people find an old notification by the words in it, with this search for React with Base UI. A compact header holds the title and one sentence over a hairline frame with a plus mark on each corner. The first band is a search field in an Input Group with a magnifier, a Kbd hint for the slash key and, once there is a query, a Clear button in the same place. The second band is a row of type chips in a Toggle Group: All, Comments, Mentions, Reviews and Updates, each with a count that follows the query. The third band holds the results in one fixed height: each has a type tile, a title and a line under it with every match marked by Search Highlight Text, and a fixed time. A count line says "5 results for “invoice”"; with no match an Empty state names the query and offers Clear. It's built from Input Group, Kbd, Toggle Group, Search Highlight Text, Empty and Guides, with a CSS entrance only. For an inbox, a knowledge base or any list worth searching.
FAQ
How do I fill it with my own notifications?
Edit NOTES at the top of the file. Each has an id, a kind (comment, mention, review or update), a title, a body line, and an ISO at time. CHIPS lists the type chips. A notification matches when its title or body holds the query, ignoring case and accents, and the marks use the same rule, so what is listed is exactly what is marked. Every count is worked out from the list, and times are shown against AS_OF.
What stays local, and how do I make it real?
The search runs over the typed list in the page; nothing is sent and nothing is stored. For a large inbox, search on your server and pass the matches to Result: keep SearchHighlightText for the marks, since it highlights whatever text you hand it. The chip counts would then come from your API's facets for the query. Results don't open anything here; in your app each title would link to its notification.
How do the slash key and Escape work?
Pressing / while focus is anywhere inside the block, except in a text field, moves focus to the search field; the block binds nothing on the rest of the page, so it never fights a site's own search. Escape in the field, or the Clear button, empties the query and keeps focus in the field. The slash hint hides on phones, where there is no keyboard.
Why do the chip counts change as I type?
Each chip says how many results it would show for the current query, so you can see where the matches are before pressing one: "invoice" finds one mention, one comment, one review and two updates, and each chip says so. The chip you pressed filters the results to its type, and the count line says how many are shown.
Is it accessible?
The field is named and sits in a search landmark. Each chip says its type and its count, "Updates, 2 results", and the pressed one is announced as pressed. The marks are real mark elements, so they read in forced-colors and in print. A polite status line speaks the count about half a second after you stop typing, rather than on every key, and the visible count is hidden from assistive technology so it isn't read twice.
How does it look on a phone?
The panel fills the width. The chips stay in one row that scrolls sideways, so a pressed chip never wraps to a second line and moves the results. The slash hint is hidden, the results keep their fixed height, and each row keeps two lines for the title and one for the line under it.
Related
- Pro
Filter Panel Notification
Sort and findAn app window with filters at its start: type checkboxes with counts, priority toggles and an unread switch narrow the list, removable chips show what is on, and an empty result offers Clear.
- 421Pro
Tabbed Inbox Notification
Bells and panelsA notification centre as a narrow panel: tabs for All, Mentions and Alerts with their own unread counts, rows you press to mark read, a mark all read for the open tab and a clear with an undo.
- 621Pro
Digest View Notification
Quiet and digestsA morning digest panel: tabs for Today, Yesterday and This week, three cells of counts that roll to each period, sections with the top three items and +N more, and an email switch that sends nothing.
- Pro
Inbox Reading Pane Notification
Bells and panelsA shared support inbox as an app window: a list of notifications under All, Unread and Archived views, and a reading pane with the sender, the time, the text, a context list and mark read, archive and undo.
- Pro
An archive of notifications as a table whose auto-delete column is worked out again when you pick a retention period, with a restore per row, an undo, and an alert dialog before it empties.
- Pro
Unread Only List Notification
Unread and countsAn inbox with an unread-only switch and a live count, where a row you read stays in place until you turn the switch off, and zero unread is a designed Inbox zero state.