Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Condensed Density Navbar Block for React

A slim 40 pixel app bar in cells on shared hairlines, with two live counts and a density control (Compact or Comfortable) that changes text size and gaps while the bar keeps its height.

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 condensed bar for React with Base UI, the strip above a logistics control tower called Kiloline. It is 40 pixels tall, in cells that share hairlines, each divider meeting the top rule with a plus: the wordmark, the five views as links (Fleet is current, marked by a stroke on the bar's bottom edge), two counts (shipments in transit and the dispatch queue) in tabular figures, and in the last cell a density control with two choices, Compact and Comfortable. Choosing one swaps the links' and counts' text size and gaps (small and tight, or larger and airier); the bar keeps its 40 pixel height in both, so nothing below it moves. On a phone the labels give way to icons (each link keeps its name) and the counts are left out. It's built from Toggle Group and Guides, with your theme's tokens for every colour. For dense operational tools, dashboards and admin consoles where every pixel of height is spent.

FAQ

How does the density control work, and does the bar move?

The block keeps the choice in density and puts the text size and the gaps on the bar from it: text-xs with tight gaps for Compact, text-sm with wider gaps for Comfortable. The column is h-10 in both, so the height never changes; only the widths do, and the control sits at the end so it stays put. Store the choice (in a cookie or your settings) and read it back into START.

Are the counts live?

They are typed data at the top of the file (COUNTS): a label and a value each, in tabular figures so a changing number doesn't shift its neighbours. Feed them from your own data; if you update them on a timer, update a hidden live region at most when they cross a limit, not on every tick.

How does it work with a keyboard and a screen reader?

The links are in a nav named Main; the current one has aria-current="page". The density control is a group named Density with two toggles, each named for what it picks, and the pressed one is announced as on. The counts are a description list (a name and its figure). Arrow keys move between the two choices; Space or Enter picks one, and the group has no empty state.

How does it work on a phone?

Below the sm breakpoint the wordmark shrinks to its icon, the views show an icon each (the name stays for a screen reader) and the two density choices show icons only. The counts are hidden below lg. Nothing wraps at 320 pixels, and the bar stays 40 pixels tall.

Does it work right to left?

Yes. The cells run from the right, the hairlines and plus marks sit on the correct edges, and the counts keep their figures in order. The wordmark is artwork and keeps its direction. Wrap the block in your direction provider (the catalog's DirectionProvider) so the toggle group follows the page.

What moves, and what about reduced motion?

The text size and the gaps ease for a moment when you change density. With reduced motion they change at once. Nothing moves on load.

  • Pro

    A two-row settings header: the page title and one real edit (a Weekly digest switch) with Discard and Save that wake up when it changes, and a row of section tabs where the dirty one carries a dot and a spoken note.

  • Pro

    Icon-Only Navbar

    Cells and splits

    An icon-only navbar for a messaging app: six destinations in square cells on shared hairlines, each named by a tooltip, with unread dots and a Show labels toggle that widens the cells to reveal the words.

  • Pro

    An app page header: a Back button, the trail with the current page's title and a Draft badge, then behind a split divider who edited it and how long ago, and a Settings link.

  • 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 dashboard bar whose page title is a menu of saved views, Pinned and Shared, with a star on the one that opens first, a breadcrumb that follows the choice and a drawer on phones.

  • Pro

    Minimal Navbar

    Link highlights

    The least navbar there is: a slim 48 px bar with a wordmark, three plain links and one Shine Button for a journaling app, with no motion, the current page marked by weight and a dot, and a bottom drawer on phones.