Skip to content
SENVENLI UI

Sidebar

The main navigation of an app: brand, sections with nested items and badges, a pinned footer, collapsible to icons.
An app's main navigation
import {
  Sidebar,
  SidebarHeader,
  SidebarItem,
  SidebarSubmenu,
  SidebarSection,
  SidebarFooter,
} from "@senvenli/react/navigation";

Examples

Sections and a pinned account

Labelled sections scroll between the brand and the account, which stay in view.

Composed from parts

The same navigation built from `SidebarItem`, `SidebarSubmenu` and `SidebarSection`, with the brand and the account as `SidebarHeader` and `SidebarFooter`.

Collapsed to icons

56px wide, labels in tooltips; the toggle at the bottom expands it.

Guidelines

When to use it

  • Navigating an app with several sections.

Use something else when

  • A public site with few pages. Navbar

Accessibility

Keyboard

KeysWhat happens
TabMoves through the links.

Built in

  • The current page is marked with aria-current.
  • Under 1024px it becomes a panel opened from the header.
  • Collapsed, the rail shows the logo and the account's avatar alone; the brand name stays the link's accessible name.

You provide

  • Section names.
  • With children: a unique id on every SidebarItem and SidebarSubmenu (currentKey matches it), or isCurrent on the page's item.

API reference

Sidebar

brand
React.ReactNode

The product name, after logo (or the logo and name together). It links to brandHref. Or a SidebarHeader child.

logo
React.ReactNode

The app's mark (an Icon or an image) before brand. Collapsed, the rail shows it alone, centred; the name stays the link's accessible name. Without it, collapsed shows the start of brand.

brandHref
string
items
readonly SidebarItemData[]

The top-level items (links, or groups with children); five to eight is the comfortable range. With sections, these are the unlabelled items above the labelled sections (a dashboard) and may be empty. Ids are unique across items and sections (a repeated id marks two items as the current page). Leave it out to compose the navigation as children instead.

children
React.ReactNode

With no items: the navigation composed from SidebarItem, SidebarSubmenu and SidebarSection (loose items first, then the sections), plus an optional SidebarHeader (instead of brand) and SidebarFooter (instead of footer).

sections
readonly SidebarSectionData[]

Labelled sections under items, in order. Each is a named group with an overline; collapsed, the overline is visually hidden (the group keeps its name) and a separator stands in for it. Not collapsible. Left out (or empty), the Sidebar renders exactly as before.

currentKey
string

The id of the page's item: marked aria-current="page"; its group stays open.

footer
React.ReactNode

The account at the bottom: name and role after avatar (or Avatar, name and role together). Or a SidebarFooter child.

avatar
React.ReactNode

The account's Avatar before footer. Collapsed, the rail shows it alone, centred, and footer is hidden. Without it, collapsed shows the start of footer.

isFooterPinned
boolean

Keeps the account (footer) and the collapse toggle in view at the bottom: the brand stays at the top and only the navigation (items, then sections) scrolls between them, expanded and collapsed. In the phone panel the account stays at the bottom the same way. The DOM order, and so the Tab order, is the same as without it. Off by default: the whole sidebar scrolls as one, as before.

isCollapsed
boolean

Icons only (56px), labels in tooltips. Controlled; or defaultCollapsed + onCollapsedChange.

defaultCollapsed
boolean
onCollapsedChange
(isCollapsed: boolean) => void
storageKey
string

Remembers the collapsed choice in localStorage under this key. Render sidebarScript(storageKey, { defaultCollapsed }) in <head> as well, with the same defaultCollapsed, so the first frame already has the remembered width (no layout jump). Uncontrolled only: with isCollapsed the app owns the state.

isMobileOpen
boolean

Under 1024px the sidebar is a menu panel from the start edge; the app's menu button opens it.

onMobileOpenChange
(isOpen: boolean) => void
aria-label
string

Names the navigation landmark; "Main menu" by default.

motion
ComponentMotion

auto (follow the device), reduce or none, for this component; the provider's setting otherwise.

SidebarHeader

children
React.ReactNode

The product name (or the logo and name together); it links to the Sidebar's brandHref.

logo
React.ReactNode

The app's mark before the name; collapsed, the rail shows it alone. As the Sidebar's logo.

SidebarItem

idRequired
string

Unique in the sidebar; currentKey matches it.

labelRequired
string

A noun for the page ("Orders"); also the tooltip when the sidebar is collapsed.

icon
IconName

Lucide name; top-level items carry one (it is all a collapsed sidebar shows).

href
string
badge
{ value: number; tone?: BadgeCountTone | undefined; }

A count ("4 new"): a Badge after the label, on the icon when collapsed.

isCurrent
boolean

Marks this item as the page in view, instead of the Sidebar's currentKey.

SidebarSubmenu

idRequired
string

Unique in the sidebar; currentKey matches it.

badge
{ value: number; tone?: BadgeCountTone | undefined; }

A count ("4 new"): a Badge after the label, on the icon when collapsed.

icon
IconName

Lucide name; top-level items carry one (it is all a collapsed sidebar shows).

labelRequired
string

A noun for the page ("Orders"); also the tooltip when the sidebar is collapsed.

childrenRequired
React.ReactNode

The nested SidebarItems, shown indented when it is open.

SidebarSection

id
string

Also on the DOM as data-section.

labelRequired
string

The overline over the items, already translated; it names the group, also when collapsed.

childrenRequired
React.ReactNode

SidebarItems and SidebarSubmenus.

SidebarFooter

children
React.ReactNode

The account's name and role (or Avatar, name and role together).

avatar
React.ReactNode

The account's Avatar before the rest; collapsed, the rail shows it alone. As the Sidebar's avatar.