shadcn.io is not affiliated with official shadcn/ui
Operator Chip Search Navbar Block for React
A mail navbar for an email app with a search field that turns from:, to:, has: and is: operators into removable chips and counts the matches.
Installation
Overview
A mail navbar for React with Base UI, the bar of Mailwick, email for teams. A row of cells follows the wordmark: Inbox with a count of unread messages, Sent, Drafts and Starred, then a search field built from chips. Type from:ana, to:design, has:attachment, is:unread or is:starred and press Enter or a comma: the text becomes a removable chip. A second Backspace on an empty field removes the last chip, and plain words become text chips. While the field has focus a small panel lists the operators; Escape closes it. The count beside the field is worked out from the twenty sample messages in the file, and a polite line says what each change did. Compose is the one Shine Button. On a phone the field moves into a sheet from the top, opened by the search icon, with the folders under it. The page's rails and top rule come from the Guides spine, interior hairlines meet that rule with a plus, and the bar stays 56 pixels high. It's built from Tags Input, Badge, Sheet, Button, Shine Button and Guides. For mail, support and ticketing tools whose search is the main control.
FAQ
Which operators work, and what happens with a mistake?
from: and to: take a name and match it as a part of the sender or the recipient, so from:ana also finds Hana. has:attachment keeps the messages with a file, and is:unread and is:starred filter by state. Any other text is a text chip that matches the subject or the sender. Chips combine: a message must match all of them. A half-written operator is refused with a line in the panel, for example "from: needs a name, like from:ana.", a repeated chip is refused, and the field holds five chips.
Where do the counts come from, and do they search my mail?
Nothing leaves the page. The count ("8 of 20") is worked out in the browser from the MAIL array at the top of the file, and the number on Inbox is the unread messages in that array. Replace the array, or call your search from the chip handler, to make it real. The sample is example data.
How does the field work with a keyboard and a screen reader?
The field is a text input named Search mail inside a search landmark. Enter and comma commit a chip, and Backspace on an empty field first marks the last chip and then removes it. Each chip has its own delete button, and the field has a Clear all button once there is a chip. Focus opens the operator panel, Escape closes it and puts focus back in the field, and the buttons in the panel add a chip or write the operator into the field. A polite line announces each change ("Added from:ana. 3 of 20 messages match."), and it speaks only when something changes.
How does it fit on a phone?
Below md the links and the field leave the bar. A search icon opens a sheet from the top with the same field, the operators as plain buttons, the count, and the folders. A dot on the icon and its name ("Search mail, 2 filters") show that chips are set. The chips are shared with the bar, so resizing keeps them. Compose becomes an icon, and its name stays for screen readers.
Escape closes the sheet and returns focus to the search icon.
How do I point Compose at a real composer?
Compose is a link to #. Point its href at your composer.
The Shine Button renders the link with render, with nativeButton={false}.
What moves, and what happens with reduced motion?
Nothing moves on load. The operator panel fades in over 150 ms and links change colour; both are instant with reduced motion. A band of light sweeps across Compose once on hover and keyboard focus, and with reduced motion that light fades in where it stands.
Related
- Pro
Expandable Search Navbar
SearchA navbar for a recipe library whose search button grows a field inside the bar, pushing the links aside on shared grid tracks, with a clear button, an Esc hint and a live count of matching recipes.
- Pro
Command Palette Navbar
SearchA navbar for a notes app with a field-looking button and a shortcut that open a command palette: recent notes first, then pages, actions and settings in labelled groups, with the keys that work shown beside each row.
- Pro
Keyboard Shortcuts Navbar
App toolbarsAn app navbar whose shortcuts work: G then H, P or S moves between pages, a question mark opens a dialog with every key in a table, and each link shows its keys on hover and keyboard focus.
- Pro
Pinned Message Chat Navbar
Page headersA conversation header for a team chat app: the channel name and member count, a one-line pinned message that cycles to the next pin when pressed, member avatars and Voice and Video call links with tooltips.
- Pro
Create Menu Navbar
App toolbarsAn app bar with a Shine Create button that opens a grouped menu with working key hints and a New from template submenu, and a bottom drawer with the same rows on phones.
- Pro
Notification Bell Navbar
Meters and progressAn app navbar for a team inbox with a bell whose count follows what you do: the bell opens a panel with All and Unread tabs, rows you can mark read, mark unread or dismiss, and Mark all as read, and a drawer on phones.