shadcn.io is not affiliated with official shadcn/ui
Dark Theme Sidebar Block for React
A developer console in a fixed-height window with three sidebar surfaces made only of theme tokens (flush, tinted and raised), so the rail is right in every preset and in dark mode, beside a terminal that stays dark by nature.
Installation
Overview
Give a developer tool a rail that follows its theme with this dark theme sidebar for React with Base UI. A window framed by a hairline with a plus mark on each corner holds the Sidebar with five console pages, and a Segment Group in the top bar changes the rail's surface between three looks, each built from tokens alone: Flush paints the page's own --background with a hairline edge, so the rail and the page are one surface, Tinted paints --muted with no edge, and Raised paints --card as a floating card, with a ring and a shadow, on a --muted shell. Because nothing is a fixed color, every one is right in every preset, light and dark, and the page itself is never forced dark. The only dark part is the terminal beside the rail, which shows six typed lines for the chosen page, the last two echoing the surface; a short list names the tokens in use. Below the medium breakpoint the rail is a sheet with the theme's own sidebar surface. It's built from Sidebar, Segment Group, Avatar and Guides, with a CSS entrance only. For developer consoles, admin tools and any app whose rail should look chosen, not forced.
FAQ
How can a dark-looking rail follow the theme?
The surfaces are tokens, not colors: the provider overrides --sidebar (what the rail's bg-sidebar reads) with --background, --muted or --card, and sets --sidebar-accent to a mix of foreground and that surface so hovered and current rows still show. In a dark preset those tokens are dark, so the rail is dark there and light elsewhere, and a Tinted rail never needs a dark: class. Raised also switches the Sidebar to variant="floating", which adds the card's radius, border and shadow.
Why is the terminal dark in a light theme?
A terminal is dark by nature, so the figure keeps a dark scope on its own element and nowhere else; a comment in the file says so. The rest of the window follows the theme. If you would rather it followed the theme too, delete the dark class and the terminal turns light in light presets.
What stays in the page, and how do I connect it?
Everything. Each console page's command and its three lines of output are typed in PLACES, and the surface switch only changes a class on the provider; nothing is run, deployed or saved. 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. In your app, pick one surface and drop the switch.
How does it work on a phone?
Below the medium breakpoint the sidebar is a sheet that opens outside the window's own element, so the provider's tokens don't reach it and it always keeps the theme's own --sidebar surface. The surface switch is therefore hidden there, and the page says so. The menu button in the top bar opens the sheet from the start edge, the right in a right-to-left layout; Escape or choosing a page closes it and focus returns to the button.
Are all three surfaces readable?
Yes: group labels and the secondary lines use the sidebar's full foreground rather than a faded one, and the rows' hover and current fills are mixes built on each surface, so text keeps its contrast on all three. Icons use the sidebar's own muted tone, which is for graphics and not for words. The block was checked in light and dark presets.
Is it accessible?
The rail is a navigation landmark named after the product with its group named by its label, and the open page is marked as the current page. The surface switch is a labeled group of three options with arrow-key movement, and one polite status line says which surface is on. The terminal is a figure with its lines as a list, read in order, and the page scrolls inside its own region that takes keyboard focus.
Related
- Pro
Floating Variant Sidebar
VariantsA CSS toolkit's docs in a fixed-height window with a floating sidebar: a rounded card inset from the window over a tinted shell, five collapsing sections of pages, and a switch to the flush rail for comparison.
- Pro
Inset Variant Sidebar
VariantsAn issue tracker in a fixed-height window with an inset sidebar: the rail's tint fills the window and the page is a raised, rounded panel of issues filtered by view and label.
- Pro
Compact Icon Rail Sidebar
Icon railsA note-taking app in a fixed-height window whose narrow rail keeps a caption under every icon, with a pill on the open destination, a dot on Inbox while it holds unopened notes and Alerts and Settings pinned at the foot.
- Pro
Brand Header Sidebar
Headers and sectionsA 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.
- Pro
Offcanvas Sidebar
VariantsA reading app in a fixed-height window whose sidebar slides fully out of view, so the article's line length grows from 62 to 78 characters; the trigger, the edge rail and Ctrl or Command with B bring it back.
- Pro
Controlled State Sidebar
State and themingA layout playground in a fixed-height window with a controlled sidebar: Open, Close, Toggle, a switch and Ctrl or Command with B all drive the provider, and every onOpenChange call is logged with where it came from.