Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Top Bar Shipping Banner Block for React

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

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 delivery check for React with Base UI, a shop's free-shipping line that answers instead of just promising. For Shuttlehq, a tea shop, a faint tinted band holds a truck, the label "Deliver to", a small postcode field with a Check button inside it, and at the end the answer. Before anything is typed it states the free-shipping threshold, "Free delivery on orders over £40". Press Enter or the button: a valid postcode gets "Free 2-day delivery to SW1A 1AA", the Highlands and islands get four days, and anything else gets "Enter a postcode like SW1A 1AA" with the field marked invalid. The four answers share one grid cell, so the strip stays 44 pixels tall whichever shows, and a polite status line speaks the answer when it changes. On a phone the answer drops under the field. It's built from InputGroup, Shine Button and Guides with Lucide icons and your theme's tokens for every colour, and it follows the theme. For shops that ship to a region and want visitors to see the promise apply to them.

FAQ

How do I change what counts as valid and how long delivery takes?

The check is two small functions at the top of the file. POSTCODE is a pattern for UK postcodes (an outward code and an inward code, with or without the space), and REMOTE lists the areas that take longer (IV, HS, KW and ZE). Edit them for your country and your carrier, or replace check with a call to your shipping API; it only has to return one of the four answers and the postcode as it should be written.

Why does the strip never change height?

The four possible answers sit in one grid cell, stacked on top of each other; only the current one is visible and the rest are invisible and hidden from screen readers, so the cell is always as tall as the tallest. The bar is therefore 44 pixels whether the answer is the threshold, a delivery time or the error, and nothing below it moves.

How do screen readers get the answer?

A polite status line is on the page from the start and stays empty until a check runs, then holds the answer, so it's announced once. Editing the field clears it again. The visible answer is also tied to the field with aria-describedby, and the field is marked aria-invalid when the postcode can't be read.

Why is the Check button a Shine Button?

It's the strip's one action, so it takes the same button as every other primary in these blocks, in its outline form and extra-small size so it fits inside the field and keeps the bar at 44 pixels. It's a submit button in a form, so Enter in the field does the same thing.

What does it look like on a phone?

The label, field and button share the first line (the truck icon is dropped) and the answer is on the second, so the strip is two lines at most, about 72 pixels at 320. In a right-to-left page the order mirrors, and the answer's text sits in a bdi so the postcode keeps its order.

  • Pro

    A region callout for a storefront: two cells split by a divider, a map pin and a live line at the start, and a US, EU and UK segment control at the end that rewrites the currency, tax and delivery line.

  • Pro

    A checkout trust strip split by a divider: outline chips for the ways to pay at the start, a lock and a secure-checkout note with a link at the end.

  • Pro

    An early-access signup for a design studio: a labelled email field with the Shine Button inside it, a validation message, a polite success line and a ghost Remind me later.

  • Pro

    A centred rating strip: five stars drawn filled to 4.8, the score with its review count, and a link to leave a review.

  • Pro

    A flash-sale countdown for a lighting shop: the product with its struck regular price and sale price, a clock of hours, minutes and seconds in three cells, a Shine Button to claim the price, and a thin meter of how much stock is claimed.

  • Pro

    A top bar for a notes app that teases its annual price: the percentage off worked out from the two prices, the monthly price struck through, the annual one beside it and an Upgrade link.