Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Editorial Category Menus Navbar Block for Radix UI

A one-bar navbar for a long-form publication whose five category triggers each open a small panel of that category's three latest pieces, with reading times as outline badges and an All stories link, and accordion groups in a sheet on phones.

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

An editorial navbar for React with Radix UI, for a publication that wants a reader to see what's new before choosing a section. The masthead leads (an icon and the name, set by weight alone: the name bold, the word after it regular); Essays, Reviews, Interviews, Reportage and Notes each open a 320-pixel panel under their own button with that category's three latest pieces, each a title and an outline badge with its reading time, and an All stories link under a hairline. A Subscribe Shine Button ends the bar. Below the lg breakpoint a menu button opens a sheet from the top where each category is an accordion group with the same three pieces and the same link, and Subscribe sits below them. The panels and the sheet open over the page, so the block stays one bar high (56 pixels), and the bar draws no bottom border: the next block's top rule is its bottom edge. It's built from Navigation Menu, Accordion, Badge, Sheet, Guides, Shine Button and Button, with your theme's tokens for every colour. The titles and times are example copy. For magazines, newsletters and blogs whose categories are the way in.

FAQ

Why do the panels open under their own button?

Each category is its own menu, and a small panel reads best right under what opened it, so each panel is anchored to its trigger. The Navigation Menu is set to viewport={false}, so each panel is its own element under its button (the shared viewport would put every panel under the first).

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

The links sit in a nav landmark named Main, after the masthead (a link home). Tab reaches the masthead, the five category buttons and Subscribe. Enter or Space opens a menu, its button says whether it is expanded, and Escape closes it and puts focus back on its button. Each panel's pieces and its All stories link are a plain list of links. Focus stays on the category button when it opens; the Down arrow or Tab moves into the panel, the arrow keys move between its links and along the bar, and Home and End jump to the bar's first and last item. The menus also open on hover.

How does it work on a phone?

Below the lg breakpoint (five categories need the width) the masthead, Subscribe and a menu button stay on the bar, and nothing wraps at 320 pixels. The menu button says whether the menu is open and which panel it controls; it opens a sheet from the top whose header lines up with the bar. The categories are accordion groups, closed at first and one open at a time, each holding its three pieces with their reading times and an All stories link; Subscribe sits below, full width. Focus moves into the sheet and stays there; Escape, the close button or choosing a link closes it, and focus goes back to the menu button. A sheet taller than the screen scrolls.

Does choosing a link close the menu?

Yes, in the panels and in the sheet, so a client-side route change that keeps the navbar mounted doesn't leave a menu open over the new page. The Navigation Menu closes itself when one of its links is chosen. The sheet's open state is held in the block too (sheetOpen), and each of its links closes it. Every link points at #: point them at your pages. Subscribe takes asChild with the link inside, so it can be your router's link.

How does it sit on the page, and can it stick to the top?

The navbar is the page's first block: its + marks and rails line up with every block under it, its top rule falls on the window's top edge, and it draws no bottom border, because the next block's top rule is its bottom edge. To keep the bar in view while the page scrolls, add sticky top-0 z-40 bg-background/80 backdrop-blur to the header; the menus still open under it. With reduced motion the panels and the sheet appear without their fades and slides.