Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Cart Sheet Preview Navbar Block for React

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.

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 with a working bag in React with Base UI. The wordmark of Thimbleberry, a craft-supply shop, leads, and Yarn, Fabric, Notions and Kits follow as plain links, the current page marked by a foreground stroke on the bar's bottom edge. At the end of the bar a bag button shows how many things are in it; pressing it opens a sheet from the end of the page with three lines, each with a stepper that never goes below one, a remove button and its own total. Above the lines a meter says "You’re $16.00 away from free shipping" and fills as the bag grows; below them the subtotal is worked out from the lines, with a Checkout Shine Button. Every figure is derived from the same list, so the bar's count, the meter, the subtotal and the line totals follow each change, a polite status says what changed, and removing the last line leaves an empty state. On a phone the sheet nearly fills the screen and a menu button opens a sheet from the top with the links. It's built from Sheet, Progress, Badge, Button, Navigation Menu, Shine Button and Guides. For stores where a shopper checks the bag without leaving the page.

FAQ

How do I use my own bag?

Edit START at the top of the file (an id, a name, a note, an icon, a price in cents and a quantity), FREE_FROM for the shipping threshold in cents and MOST for the largest quantity. In a real store, replace the useState with your cart's state and keep step and remove as the two ways it changes.

Where do the figures come from?

Nothing is typed twice: countOf and subtotalOf read the lines, the meter's remainder is the threshold minus the subtotal (so it reaches "Your bag ships free" on its own), and each line's total is its price times its quantity. Prices are cents, formatted by one money() helper, and each amount sits in its own left-to-right span so a currency sign never moves in right-to-left layouts.

How does it work with a keyboard?

The bag button opens the sheet and moves focus into it; Escape or the close button closes it and focus returns to the bag button. Inside, each line has a fewer button, a more button and a remove button. At one, the fewer button stays focusable but does nothing (it is aria-disabled, so focus is never dropped). Removing a line moves focus to the remove button that took its place, or to Continue shopping when the bag is empty.

How do screen reader users hear a change?

A polite status inside the sheet is empty until something changes, then says, for example, "Merino worsted: 3. Subtotal $38.00, 5 items." The bag button's own name carries the count ("Bag, 4 items"), and the meter is decoration: the sentence above it says the same thing.

How does it work on a phone?

Below md the links fold into a menu button that opens a sheet from the top, and the bag button stays in the bar, shrinking to its icon and count. The bag sheet takes the screen but for a sliver, and its list scrolls while the header, meter and subtotal stay put. It fits at 320 pixels.

Which edge does the sheet open from?

The end of the page: the right edge in left-to-right layouts and the left edge in right-to-left ones, where its border moves to the other side too.

  • Pro

    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.

  • 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

    Drill-Down Drawer Navbar

    Mobile and drawers

    A drawer navbar for a travel planner: a Menu button at every width opens a sheet from the end where Plan and Explore slide a second panel in with a Back button, with Pricing and Help centre as plain links and a Shine Button at the foot.

  • Pro

    A delivery check in a slim bar: type a postcode, press Check, and the bar answers with the delivery time in place.

  • Pro

    Spend controls as a selling point: a circular gauge of spend against a monthly cap set with a slider, email alerts at 50, 80 and 100% of the cap, and the choice of pausing jobs or keeping them running when the cap is reached.

  • Pro

    Balance Chip Fintech Navbar

    Shops and services

    A navbar for a personal-banking app with a balance chip and an eye toggle that hides the amount behind dots without changing the chip's width, a vertical divider and the account's avatar.