Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Department Search Ecommerce Navbar Block for React

A one-bar navbar for a home-goods store: a department select joined to a search field whose popup lists products with their prices, and a bag whose count follows what you choose.

Framework
UI library

Preview

Preview width

Installation

Part of Pro
Pro unlocks the code and one-line install of every Pro button and text effect, plus the MCP for your AI editor.
Have Pro already? Sign in to open it.Opens here as soon as you're Pro.

Overview

A navbar for an online store in React with Base UI. The wordmark of Bramblecart, a home-goods shop, leads, and Shop, New in, Sale and Gift cards follow as plain links, the current page marked by a foreground stroke on the bar's bottom edge. The search is one joined control: a department select (All, Kitchen, Garden, Lighting) and a field. Typing opens a popup of products from that department, each with a greyscale thumbnail, its name with the matching letters marked, its department and its price; choosing one puts it in the bag, and the count beside the bag follows while a polite status says what was added. A vertical divider splits the shopping side from the bag side. The popup is portalled, so the bar keeps its height while it 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 links. It's built from Autocomplete, Native Select, Input Group, Badge, Navigation Menu, Sheet and Guides. For stores whose shoppers search before they browse.

FAQ

How do I use my own products?

Edit PRODUCTS at the top of the file (a name, a department, an icon, a price in whole dollars and a value) and DEPARTMENTS for the select's options. The popup's rows, the filter and the empty message all read them. Prices are formatted by one money() helper in a single left-to-right span, so a currency sign never moves in right-to-left layouts.

What does choosing a product do?

In this demo it adds one to the bag's count and says so in a polite status ("Brass table lamp added to your bag. 3 items in your bag."); nothing is sent anywhere and the count resets when the page reloads. Replace add with your own cart call. On a phone the search closes after an add, so the new count is visible, and focus goes back to the search button.

How does the department scope the results?

The select is a native one, so it uses the phone's own picker. Changing it re-filters the popup at once; with nothing left it says "Nothing in Kitchen matches …" instead of an empty list. The select comes before the field in the tab order.

How does it work with a keyboard?

Tab reaches the department select, then the field. Typing opens the popup; the arrow keys move through the rows, Enter adds the highlighted product, and Escape closes the popup first and, with the popup closed, ends a phone's search. The Autocomplete is the same on every base.

How does it work on a phone?

Below md the bar shows the wordmark, a search button, the bag and a menu button. The search button (aria-expanded, aria-controls the search landmark) swaps the bar for the field, which takes the keyboard; Escape or the close button brings the bar back and focus returns to the search button. The links wait in a sheet from the top.

How does it sit on the page?

It's the page's first block: its + marks and rails line up with every block under it, and it draws no bottom border because the next block's top rule is its bottom edge. The popup drops below the bar and never changes its height.

  • Pro

    Cart Sheet Preview Navbar

    Shops and services

    A one-bar navbar for a craft shop whose bag button opens a sheet from the end: steppers, remove buttons, a free-shipping meter and a subtotal worked out from the lines.

  • Pro

    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.

  • Pro

    A 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

    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

    A 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

    An admin navbar for a marketplace console: a sidebar toggle, a search field scoped to Users, Orders or Logs, and a badge that counts pending approvals.