Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Sub-Navigation Navbar Block for React

A two-row header whose second row shows the chosen section's four links, the three link sets cross-fading in one grid cell, with the current section and the current page both marked.

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 two-level header for React with Base UI, for an API gateway called Gatelatch. One bar and a sub-bar between the page's rails; the second row's rule is a solid hairline with + marks on the rails. The first row holds the wordmark, three sections (Product, Docs, Company) and, from sm, a Shine Button; the second row holds the chosen section's four links: Gateway, Rate limits, Plugins and Pricing; Quickstart, Guides, API reference and Changelog; About, Customers, Careers and Contact. The three sets share one grid cell as wide as the widest, the chosen one shows, the others are invisible and inert, and choosing a section cross-fades them and lands on its first page. Both levels say where you are: the section with aria-current="true" and a foreground stroke on the first row's bottom edge, the page with aria-current="page" and a tint. On a phone the second row scrolls sideways with faded edges and keeps the chosen page in view. The header is about 108 pixels tall (100 on a phone). It's built from Guides, Shine Button and Button, with your theme's tokens for every colour. For documentation and product sites with sections that each have their own pages.

FAQ

How do I change the sections and their pages?

Edit SECTIONS at the top of the file: each section has an id, a label and its list of pages (an id and a label). The first row, the second row's link sets and the polite lines are built from it; the first page of a section is where choosing the section lands. Pages and the product are made up for the demo. In an app, derive the current page from the route and make each link a real link: the block's goSection and goPage only keep the state and stop the demo's # links from jumping.

Why doesn't the second row jump when the section changes?

The three link sets are uls in one grid cell, so the cell is as wide as the widest set. The chosen set is visible; the others are invisible, transparent, inert and hidden from assistive technology, so they take no focus and are never read.

Why are there two kinds of aria-current?

The first row's items are sections, not pages, so the one you are in carries aria-current="true"; the second row's items are pages, so the current one carries aria-current="page". The first row is a nav named Main and the second a nav named after the section ("Docs pages"). After a choice a hidden status line says, for example, "Docs: Quickstart."

How does it work on a phone?

The header stays two rows (100 pixels) with nothing in a menu: the first row shows the wordmark's icon and the three sections, and the second row scrolls sideways with faded edges. Choosing a section or a page scrolls the chosen page to the middle of the row (instantly under reduced motion). Sign in appears from md and the Shine Button from sm; below that, link them from your page or add a sheet.

Does it work right to left?

Yes. Both rows mirror, the sub-row's first link starts at the end edge and scrolls toward the start, and the wordmark is artwork and keeps its direction.

What moves, and what happens with reduced motion?

The link sets cross-fade in 200 milliseconds and the phone's row scrolls smoothly to the chosen page. With reduced motion the sets swap and the row jumps at once.

  • Pro

    Contextual Navbar

    Cells and splits

    A navbar with a Site | App segment control whose two link sets and action sets cross-fade in one grid cell, so the bar's width and height never change.

  • Pro

    Role-Based Navbar

    Accounts and scopes

    An app bar with a View as toggle (Admin, Editor, Viewer) that swaps the bar's links in one cell, so its width never moves, with a role badge that says what the role can do.

  • Pro

    A two-row navbar: utilities on top (Support, Docs, Status, a language menu, an account menu) and the main tabs below, where only the lower row stays stuck on scroll, by CSS alone.

  • Pro

    A two-row navbar for a stationery subscription: a promo row with a discount code and a Copy button that folds away when dismissed, above a standard bar with four links, Sign in and a Shine Button.

  • Pro

    Tabs Underline Navbar

    Link highlights

    A navbar for a financial reporting tool built as cells: the wordmark in its own cell, full-height report tabs whose 2 px mark sits on the bar's bottom edge and slides on selection, and an Export action, with arrow-key navigation and a scrolling tab row on phones.

  • 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.