shadcn.io is not affiliated with official shadcn/ui
Editorial Category Menus Navbar Block for Solid
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.
Installation
Overview
An editorial navbar for Solid with Ark 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
How do I change the categories and the pieces?
Edit CATEGORIES at the top of the file. A category has an id, a label and three pieces, each a title, a number of minutes (shown as 14 min, kept together in right-to-left pages) and an href. The panels and the sheet read the same data, so they never drift apart. Keep a title to about two lines at 320 pixels: the badge sits beside it and never shrinks. If a category has more than three pieces, add the fourth to the data and the panel grows; keep it under about 420 pixels.
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. Each panel starts under its button, and shifts toward the page only when there isn't room.
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.
Opening a menu moves focus to its first piece; Tab walks the three and All stories and carries on to the next button, and the menu closes as focus leaves it. The menus open on click, not 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 open menu is held in the block (open, one id at a time), and each link closes it.
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's asChild receives its props: spread them onto 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.