Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Scrollable Content Sidebar Block for React

An all-in-one workspace in a fixed-height window whose wide sidebar scrolls six groups of pages under sticky group labels, with a line that says which group is at the top and a Jump to select that scrolls to one.

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

Keep a long menu readable as it scrolls with this scrollable content sidebar for React with Base UI. A window framed by a hairline with a plus mark on each corner holds a wide Sidebar of six groups, Overview, Content, Communication, Analytics, Developer and Settings, with twenty-nine pages between them. Each group's label sticks to the top of the scroll area while its pages go by underneath, and the next group's label pushes it off. A line under the brand names the group at the top, worked out from the scroll position, for example Group 3 of 6: Communication, and a Jump to Native Select scrolls the list to any group and keeps the line in step. The brand, the select and your account stay pinned. Folded to icons, the rail shows every page's icon with a tooltip; on a phone it is a sheet. The page shows the chosen page's title and three lines. It's built from Sidebar, Native Select, Field, Badge, Avatar and Guides, with a CSS entrance only. For workspaces, consoles and any menu with many groups.

FAQ

How do the labels stick?

Each SidebarGroupLabel is position: sticky at the top of the scroll area with the sidebar's own background, and its group is the label's containing block, so it leaves with its group and the next label takes its place. There is no script: scrolling is the browser's, and the labels keep a hairline under them so the pages passing under read as covered.

How is the group at the top worked out?

The block listens for scroll on the document, in the capture phase, since the scroll area's events don't bubble, and keeps the ones from its own list. The group at the top is the last one whose top edge is at or above a line just under the scroller's top. At the very bottom the last group counts as at the top, even if it is too short to reach it.

How does Jump to scroll, and what is said?

Choosing a group sets the scroller's scrollTop so the group's top meets the top edge, never scrollIntoView, which would move the page around the window. A group near the end can't reach the top because the list can't scroll that far, so the block remembers where the jump left the list and keeps that group as the one at the top until you scroll away. The polite status line says the group about half a second after scrolling rests, so it isn't read out mid-scroll.

What happens when the sidebar folds to icons?

The select, the line and the labels go, and every page shows its icon with a tooltip, so the strip lists all twenty-nine pages whatever the scroll position was. The strip scrolls too. Unfolding brings the select back showing the group at the top.

What stays in the page, and how do I connect it?

Everything. The twenty-nine pages and their lines are typed in GROUPS; nothing is fetched or saved, and the block sets persist={false} and shortcut={false} so it writes no cookie. The pages are links to # whose handler shows the page instead of navigating. They're SidebarMenuButtons with render set to an a element. Point them at your routes and mark the current one with isActive and aria-current.

How does it work on a phone?

Below the medium breakpoint the sidebar is a sheet that the menu button in the top bar opens from the start edge, the right in a right-to-left layout. Jump to is a native select, so it opens the phone's own picker inside the sheet. Choosing a page closes the sheet and puts focus back on the button.

  • Pro

    Sticky Header Sidebar

    Headers and sections

    A store admin in a fixed-height window whose sidebar keeps its header and footer in place over eighteen scrolling pages, with a hairline that appears only while there is something to scroll, a filter, and a Back to top button.

  • Pro

    An HR portal in a fixed-height window whose sidebar is a people directory: 24 people under sticky letter headings with an A to Z rail that jumps to a letter, and a card for the chosen person with a manager button.

  • Pro

    A framework's docs in a fixed-height window whose slim sidebar has five groups that fold from their labels, with Expand all and Collapse all, a count of open groups and a dot on a folded group that holds the current page.

  • Pro

    A help centre in a fixed-height window whose wide sidebar folds three levels deep, categories that hold topics that hold articles, with a Reveal active button that opens only the folds above the open article.

  • Pro

    A hosting platform's settings console in a fixed-height window where the sidebar's width is the control: four presets set its CSS variable, and a measured count shows how many of ten long labels get cut at each.

  • Pro

    Brand Header Sidebar

    Headers and sections

    A design-operations suite in a fixed-height window whose sidebar header is a brand lockup that opens a menu to go home, copy the logo name, copy the mark as SVG or open the brand guidelines.