Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Tooltip Menu Sidebar Block for React

A messaging app in a fixed-height window whose icon rail opens a menu card beside each icon on hover or focus, with the section's name, one line and its links; choosing a link sets the page and the top bar shows the path.

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

Put a section's links one hover away from its icon with this tooltip menu sidebar for React with Base UI. A window framed by a hairline with a plus mark on each corner holds the Sidebar, folded to icons for Chats, Channels and Outbox. Rest the pointer on an icon, or move focus to it, and a card opens beside it with the section's name, one line about it and its links, each with a count: All chats, Unread and Starred; Joined, Mentions and Muted; Drafts, Scheduled and Sent. Choose a link and the page shows that list of messages in real text while the top bar names the path. The card is part of the page's tab order, so ArrowRight moves focus into it (ArrowLeft in a right-to-left layout), the arrow keys move through its links and Escape closes it with focus back on the icon. The menu button unfolds the rail to plain labels with the same links under each section, and below the medium breakpoint the rail is a sheet. It's built from Sidebar, Avatar and Guides, with CSS transitions only. For messaging, mail, admin consoles and any app where each section has a few views.

FAQ

Why is the card not a tooltip or a hover card?

A tooltip holds one line of text and can't be reached by keyboard, and a hover card's content can't be tabbed to either, so neither can carry links. This card is a plain navigation block the page draws beside the rail, absolutely positioned at the icon's height, and placed in the document right after the rail, so it sits in the tab order. It opens 90 ms after the pointer or focus arrives, moves at once from one icon to the next, and closes 160 ms after the pointer has left both the icon and the card, so crossing the small gap between them doesn't close it.

Which keys work?

Focus an icon to open its card. ArrowRight (ArrowLeft in a right-to-left layout) moves focus into the card's first link; ArrowDown and ArrowUp move through the links and wrap, Home and End jump to the first and last, and the opposite arrow or Escape closes the card with focus back on the icon. Enter on an icon opens the section's first link. Escape works from anywhere while a card is open, in the capture phase, so it isn't swallowed by another popup.

What happens when the rail is unfolded?

The cards stop: unfolded, every section shows its links as an ordinary sub-menu under its label, so nothing needs a card. The same links, counts and names serve the unfolded rail and the sheet on a phone. The block starts folded, with defaultOpen={false}, and the provider is set with persist={false} and shortcut={false}, so it writes no cookie and leaves Ctrl and Command with B to the page it sits on.

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

Everything. The fourteen messages are typed in MESSAGES, each link shows the messages one small rule picks, and the counts and the unread dots come from the same list. Replace it with your data and keep one rule per link. Nothing is sent, received or marked read. The icons are links to # whose handler shows the section's first list instead of navigating. They're SidebarMenuButtons with render set to an a element.

How does it work on a phone?

Below the medium breakpoint the sidebar is a sheet that the menu button opens from the start edge, the right in a right-to-left layout, with each section's links listed under it. Choosing one closes the sheet and puts focus back on the button; there is no hover on a phone, so the cards never open. The window keeps its height, and the status line says which list opened and how many messages it holds.

Is it accessible?

Each icon is a link named after its section and says whether its card is open. The card is a navigation block named after the section, each link's name carries its count ("Unread, 3 messages"), and the open list is marked as the current page. The top bar's heading names the path, with a decorative divider between the section and the link. One polite status line reports each choice, and the card's fade stops under reduced motion.

  • Pro

    A team workspace in a fixed-height window whose icon rail peeks open over the page on hover or focus without moving it, and a pin makes the open rail push the page and stay.

  • Pro

    A 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

    A site builder in a fixed-height window whose single sidebar is two columns: an icon rail of sections and, beside it, a panel of the browsed section's pages, with the open page kept across sections.

  • Pro

    Sub-Menus Sidebar

    Folds and trees

    A recipe manager in a fixed-height window whose floating sidebar has sections with sub-menus, a switch between One at a time and Keep open, and arrow keys that open a sub-menu toward the end of the line and close it toward the start.

  • Pro

    A features section for a realtime sync engine: a thin icon rail of six streams and a panel with the stream's name at display size beside a vertical marquee of its sync events, with a visible Pause button.

  • Pro

    Sidebar Toggle Navbar

    Mobile and drawers

    A navbar with a sidebar toggle for a project tracker: a button, the [ key and a tooltip fold a mini sidebar under the bar between icons only and icons with labels, and on phones the same button opens it as a sheet.