shadcn.io is not affiliated with official shadcn/ui
Marketplace Search Navbar Block for React
A navbar for an add-on store with a Categories menu of six categories and their counts, and a search whose popup lists add-ons with an icon tile, drawn stars, an install count and a category.
Installation
Overview
A marketplace navbar for React with Base UI, the bar an add-on store keeps above its listings. For Plugyard, the wordmark leads, a Categories menu opens a panel of six categories each with an icon and how many add-ons it holds, For developers follows as a plain link with the current page marked by a foreground stroke on the bar's bottom edge, a search field fills the middle and the shopper's avatar closes the row. Typing opens a popup of add-ons, each a row with an icon tile, its name with the matching letters marked, five small stars filled to its score with the score and the install count after them (compact, so 128K), and its category at the end. The list narrows by name or category, ignoring case and accents. Press "/" anywhere on the page that isn't a text field and the field takes focus. The popup and the panel are portalled, so the bar stays one bar high (64 pixels, 56 on a phone) while either is open. On a phone a search button replaces the bar with the field, and a menu button opens a sheet from the top with the categories, For developers and the account. It's built from Autocomplete, Navigation Menu, InputGroup, Format Number, Avatar, Sheet and Guides with Lucide icons and your theme's tokens for every colour: the stars are the text colour, never an accent. For add-on stores, plugin directories and app marketplaces.
FAQ
How do I change the add-ons and make a pick do something?
Edit ADDONS at the top of the file: a name, a category, an icon, a score out of five, an install count and a value. Picking a row puts its name in the field, as an autocomplete does. To open the listing, pass onValueChange to Autocomplete: it receives the picked value, which you can map to a route. To search a real catalogue, replace matching(query) with your own results, fetched or local; the popup renders whatever the collection holds. The categories live in CATEGORIES, with the counts typed in; derive them from your data if you have it.
How are the stars and the install count drawn, and what do screen readers hear?
Five stars are drawn in the text colour, each filled to the score by a clipped copy, so 4.6 shows four whole stars and a fifth filled by three fifths, from the inline start in either direction. The drawing is hidden from assistive technology; the row says "Rated 4.6 out of 5" in text, and the installs come from Format Number in its compact notation, in a bdi so the figure reads right in a right-to-left page. The stars use no warning colour, so the bar's only accent stays the one action on the page.
How does the Categories menu work with a keyboard?
Categories is a button that says whether its panel is open. Enter or Space opens it, Escape closes it and puts focus back on Categories, and choosing a category closes it so a client-side route change doesn't leave it open. Focus stays on Categories when the menu opens; Tab moves into the panel, and the arrow keys move along the bar and between the categories. The menu also opens on hover.
How does the search work with a keyboard and a screen reader?
The field is a combobox with an accessible name and the popup is a listbox of options. The arrow keys move through the rows, Enter picks one and Escape closes the popup, leaving focus in the field. The field declares the "/" key with aria-keyshortcuts, and the key cap is hidden from screen readers because it's a hint, not a control. The search sits in a search landmark, the menu links in a nav named Main, and the account is a link named after its owner. The popup behaves the same on every library, because it is built on the same combobox everywhere. When nothing matches the popup says what had no result.
How does it work on a phone?
Below the md breakpoint the bar shows the wordmark, a search button and a menu button. The search button says whether the search is open and which landmark it controls; pressing it (or "/") replaces the bar with the field, which takes the keyboard, and turns the button into a close button in the same place. Escape closes the popup first and ends the search second, and focus returns to the search button. The menu button opens a sheet from the top whose header lines up with the bar, with the six categories and their counts, For developers and the account; choosing a link closes it and Escape returns focus to the menu button. Nothing wraps at 320 pixels, and the popup is never wider than the screen.
Related
- Pro
A navbar for a support-desk product with a search field whose popup lists help articles and categories in two labelled groups, marks the matching letters, and offers an Ask support link when nothing matches.
- Pro
Search History Navbar
SearchA navbar for a video site with a wide search that brings back your recent searches on focus, each with a clock icon and its own remove button, narrowing as you type with suggestions beneath.
- 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
Card Grid Mega Menu Navbar
Mega menusA one-bar navbar for a design-system suite whose Products menu opens a 3 by 2 grid of cells and whose Solutions menu opens a 2 by 3 grid of industries, cells sharing hairlines, with accordion groups in a sheet on phones.
- Pro
SaaS Marketing Navbar
Mega menusA one-bar marketing navbar for a product roadmap tool: a wordmark, a Product menu of four areas with icons and one-line descriptions, plain links with the current page marked, Sign in and a Shine Button, and a sheet with the same links on phones.
- /Pro
Top Bar Search Banner
Utility barsA documentation search field in a slim bar: an icon, a labelled input and a slash key hint, with a popup of results that filters as you type.