0.1.0-rc.2

Sidebar

Sidebars provide persistent app navigation with collapsible, resizable, and mobile-responsive layouts.

Try it

Main content area beside the sidebar.

Usage

Wrap the layout in RuiSidebarProvider. Compose header, content, groups, and menu items with the sidebar sub-components.

import {
  RuiSidebarProvider,
  RuiSidebar,
  RuiSidebarHeader,
  RuiSidebarContent,
  RuiSidebarMenu,
  RuiSidebarMenuItem,
  RuiSidebarMenuButton,
  RuiSidebarInset,
  RuiSidebarTrigger,
} from '@ecopages/radiant-ui/sidebar';
 
<RuiSidebarProvider>
  <RuiSidebar collapsible="icon" defaultOpen>
    <RuiSidebarHeader>Acme</RuiSidebarHeader>
    <RuiSidebarContent>
      <RuiSidebarMenu>
        <RuiSidebarMenuItem>
          <RuiSidebarMenuButton href="/dashboard">Dashboard</RuiSidebarMenuButton>
        </RuiSidebarMenuItem>
      </RuiSidebarMenu>
    </RuiSidebarContent>
  </RuiSidebar>
  <RuiSidebarInset>
    <RuiSidebarTrigger />
    <main>Page content</main>
  </RuiSidebarInset>
</RuiSidebarProvider>

Collapsible modes

icon collapses to icons only. full hides the sidebar entirely. off keeps it always visible.

Active route matching

Enable matchActive with matchMode to highlight the current page in the menu automatically.

Theming

Sidebar surfaces map to semantic surface roles, never Tailwind palette steps:

PartCSS roles
Pane (rui-sidebar)background
Header / content / footerborder between sections
Menu buttonson-background text
Active menu buttonprimary indicator
Resize handleborder + on-surface grip, primary on hover
Insetbackground

Rounded corners use rounded-container; the collapsible pane in docs layout sits on surface-container-low. Overrides go at the theme layer, not in component CSS.

Accessibility

  • The sidebar renders as a nav landmark with label as its accessible name.
  • Collapsed icon-only mode preserves accessible names on menu buttons.
  • The trigger button exposes whether the sidebar is expanded or collapsed.

API

RuiSidebar (<rui-sidebar>) coordinates the pane, resize, collapse, and active-route matching. Compose sections with the view helpers; RuiSidebarProvider wires the shell.

Attributes (<rui-sidebar>)

AttributeTypeDefaultDescription
variantsidebar · inset · floatingsidebarPane treatment.
sideleft · rightleftWhich side the pane sits on.
collapsibleoff · icon · fulloffCollapse behavior.
defaultWidthnumberInitial width in px.
widthnumberControlled width.
minWidth / maxWidthnumberWidth bounds.
resizablebooleanfalseDraggable resize handle.
defaultOpenbooleantrueInitial open state (desktop).
mobileDefaultOpenbooleanfalseOpen state on mobile when uncontrolled (mount and when the viewport crosses into mobile).
openbooleanControlled open state. Viewport crossings do not override this.
mobileBreakpointnumberWidth below which the mobile rail applies.
labelstringSidebarAccessible name for the nav landmark.
matchActivebooleanfalseHighlight the current route in the menu.
matchModepathname · …pathnameRoute matching mode.
scrollActiveOnMountbooleanfalseScroll the active item into view on mount.
navigationEventsstring''Custom navigation events to listen for.

Attributes (<rui-sidebar-trigger>)

AttributeTypeDefaultDescription
controlsstring''aria-controls target (sidebar id).
button-labelstringToggle sidebarAccessible trigger name.
placement'' · side · …''Trigger placement.
variantghost · …ghostButton tone (reuses RuiButton variants).
sizesm · md · lgmdButton size.

Events

EventDetailDescription
rui-sidebar-toggleEmitted on every open/closed transition.
rui-sidebar-resize{ width }Emitted on every width change.
rui-sidebar-mobile-changeEmitted when the host flips mobile rail state.

View helpers

ComponentRenders
RuiSidebarProviderShell (data-layout) wrapping sidebar + inset.
RuiSidebarHeader / RuiSidebarContent / RuiSidebarFooterPane sections.
RuiSidebarSeparatorHorizontal rule.
RuiSidebarGroup / RuiSidebarGroupLabel / RuiSidebarGroupAction / RuiSidebarGroupHeaderGrouped items.
RuiSidebarMenu / RuiSidebarMenuItem / RuiSidebarMenuButton / RuiSidebarMenuActionMenu list + items.
RuiSidebarInsetMain content area.
RuiSidebarTriggerCollapse/expand trigger.

CSS classes

Public BEM classes (documented via @cssclass):

ClassDescription
.rui-sidebar · .rui-sidebar__header · .rui-sidebar__content · .rui-sidebar__footerPane structure.
.rui-sidebar__separatorHorizontal rule.
.rui-sidebar__group · .rui-sidebar__group-label · .rui-sidebar__group-action · .rui-sidebar__group-headerGroup structure.
.rui-sidebar__menu · .rui-sidebar__menu-item · .rui-sidebar__menu-button · .rui-sidebar__menu-actionMenu structure.
.rui-sidebar__menu-button--activeCurrent-page marker.
.rui-sidebar__insetMain content area.
.rui-sidebar-provider · .rui-sidebar-provider__site-header · .rui-sidebar-provider__bodyShell structure.

Theme roles

PartCSS variables consumed
Pane / inset--background
Active marker--primary
Resize handle--border, --on-surface, --primary
Surface container (docs)--surface-container-low
Rounded corners--radius-container