Search documentation

Find a component or a docs page

Sidebar

A composable, themeable and customizable sidebar component.

Usage

Example

Inset variant

Tooltips

With collapsible: :icon, pass tooltip: to SidebarMenuButton. The label shows on the right only while the sidebar is collapsed on desktop.

SidebarMenuButton(as: :a, href: "#", tooltip: "Inbox") do
  inbox_icon()
  span { "Inbox" }
end

Keyboard shortcut and state

On desktop, Ctrl+B (Cmd+B on macOS) toggles the sidebar. Each desktop toggle saves the state in the sidebar_state cookie and dispatches ruby-ui--sidebar:change with detail.open; on mobile the trigger opens the sheet instead. Read the cookie on the server to render the last desktop state.

# Initial state from the cookie
Sidebar(open: cookies[:sidebar_state] != "false") { ... }

# React to changes in your own Stimulus controller
SidebarWrapper(data: {action: "ruby-ui--sidebar:change->layout#resize"}) { ... }

Dialog variant

Installation

Components

ComponentBuilt usingSource
CollapsibleSidebarPhlex
MobileSidebarPhlex
NonCollapsibleSidebarPhlex
SidebarPhlex
SidebarContentPhlex
SidebarDocsPhlex
SidebarFooterPhlex
SidebarGroupPhlex
SidebarGroupActionPhlex
SidebarGroupContentPhlex
SidebarGroupLabelPhlex
SidebarHeaderPhlex
SidebarInputPhlex
SidebarInsetPhlex
SidebarMenuPhlex
SidebarMenuActionPhlex
SidebarMenuBadgePhlex
SidebarMenuButtonPhlex
SidebarMenuItemPhlex
SidebarMenuSkeletonPhlex
SidebarMenuSubPhlex
SidebarMenuSubButtonPhlex
SidebarMenuSubItemPhlex
SidebarRailPhlex
SidebarSeparatorPhlex
SidebarTriggerPhlex
SidebarWrapperPhlex
SidebarControllerStimulus JS