import { Button } from "@senvenli/react/action";
import { Avatar, Icon, Text } from "@senvenli/react/display";
import { Sidebar } from "@senvenli/react/navigation";
import { useState } from "react";
export default function Example() {
const [isMenuOpen, setIsMenuOpen] = useState(false);
return (
// The Sidebar is as tall as the viewport unless its parent has a height: this frame gives it one.
<div className="flex h-112 overflow-hidden rounded-ds-large border border-ds-border">
<Sidebar
logo={<Icon name="hexagon" />}
brand="Acme"
brandHref="#"
currentKey="invoices"
isMobileOpen={isMenuOpen}
onMobileOpenChange={setIsMenuOpen}
items={[
{ id: "home", label: "Home", icon: "house", href: "#" },
{ id: "orders", label: "Orders", icon: "shopping-cart", href: "#", badge: { value: 4 } },
{ id: "customers", label: "Customers", icon: "users", href: "#" },
{
id: "billing",
label: "Billing",
icon: "credit-card",
children: [
{ id: "invoices", label: "Invoices", href: "#" },
{ id: "payouts", label: "Payouts", href: "#" },
],
},
]}
avatar={<Avatar name="Sofia Marin" src="/avatars/05.webp" size="small" />}
footer={<Text>Sofia Marin</Text>}
/>
<div className="flex min-w-0 flex-1 flex-col items-start gap-ds-150 p-ds-300">
<div className="lg:hidden">
<Button variant="subtle" iconOnly iconBefore="menu" aria-label="Open menu" onPress={() => setIsMenuOpen(true)} />
</div>
<Text tone="subtle">Invoices</Text>
</div>
</div>
);
}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.import { Avatar, Icon, Text } from "@senvenli/react/display";
import { Sidebar } from "@senvenli/react/navigation";
export default function Example() {
return (
<div className="flex h-112 overflow-hidden rounded-ds-large border border-ds-border">
<Sidebar
logo={<Icon name="hexagon" />}
brand="Acme"
brandHref="#"
currentKey="orders"
isFooterPinned
items={[{ id: "home", label: "Home", icon: "house", href: "#" }]}
sections={[
{
id: "sales",
label: "Sales",
items: [
{ id: "orders", label: "Orders", icon: "shopping-cart", href: "#", badge: { value: 4 } },
{ id: "customers", label: "Customers", icon: "users", href: "#" },
{ id: "invoices", label: "Invoices", icon: "receipt", href: "#", badge: { value: 2, tone: "danger" } },
],
},
{
id: "catalog",
label: "Catalog",
items: [
{ id: "products", label: "Products", icon: "package", href: "#" },
{ id: "discounts", label: "Discounts", icon: "tag", href: "#" },
],
},
{
id: "settings",
label: "Settings",
items: [
{ id: "team", label: "Team", icon: "user-cog", href: "#" },
{ id: "integrations", label: "Integrations", icon: "plug", href: "#" },
],
},
]}
avatar={<Avatar name="Sofia Marin" src="/avatars/05.webp" size="small" />}
footer={<Text>Sofia Marin</Text>}
/>
<div className="min-w-0 flex-1 p-ds-300">
<Text tone="subtle">Shown from 1024px up. Under that, the Sidebar is a panel behind the app's menu button.</Text>
</div>
</div>
);
}Composed from parts
The same navigation built from `SidebarItem`, `SidebarSubmenu` and `SidebarSection`, with the brand and the account as `SidebarHeader` and `SidebarFooter`.import { Avatar, Icon, Text } from "@senvenli/react/display";
import { Sidebar, SidebarFooter, SidebarHeader, SidebarItem, SidebarSection, SidebarSubmenu } from "@senvenli/react/navigation";
export default function Example() {
return (
<div className="flex h-112 overflow-hidden rounded-ds-large border border-ds-border">
<Sidebar brandHref="#" currentKey="returns" isFooterPinned>
<SidebarHeader logo={<Icon name="hexagon" />}>Acme</SidebarHeader>
<SidebarItem id="home" label="Home" icon="house" href="#" />
<SidebarSection id="sales" label="Sales">
<SidebarItem id="orders" label="Orders" icon="shopping-cart" href="#" badge={{ value: 4 }} />
<SidebarSubmenu id="after-sales" label="After sales" icon="package">
<SidebarItem id="returns" label="Returns" href="#" />
<SidebarItem id="claims" label="Claims" href="#" />
</SidebarSubmenu>
<SidebarItem id="customers" label="Customers" icon="users" href="#" />
</SidebarSection>
<SidebarSection id="catalog" label="Catalog">
<SidebarItem id="products" label="Products" icon="tag" href="#" />
</SidebarSection>
<SidebarFooter avatar={<Avatar name="Sofia Marin" src="/avatars/05.webp" size="small" />}>
<Text>Sofia Marin</Text>
</SidebarFooter>
</Sidebar>
<div className="min-w-0 flex-1 p-ds-300">
<Text tone="subtle">Shown from 1024px up. Under that, the Sidebar is a panel behind the app's menu button.</Text>
</div>
</div>
);
}Collapsed to icons
56px wide, labels in tooltips; the toggle at the bottom expands it.import { Avatar, Icon, Text } from "@senvenli/react/display";
import { Sidebar } from "@senvenli/react/navigation";
export default function Example() {
return (
<div className="flex h-80 overflow-hidden rounded-ds-large border border-ds-border">
<Sidebar
logo={<Icon name="hexagon" />}
brand="Acme"
brandHref="#"
currentKey="orders"
defaultCollapsed
items={[
{ id: "home", label: "Home", icon: "house", href: "#" },
{ id: "orders", label: "Orders", icon: "shopping-cart", href: "#", badge: { value: 4 } },
{ id: "customers", label: "Customers", icon: "users", href: "#" },
{ id: "reports", label: "Reports", icon: "chart-column", href: "#" },
]}
avatar={<Avatar name="Sofia Marin" src="/avatars/05.webp" size="small" />}
footer={<Text>Sofia Marin</Text>}
/>
<div className="min-w-0 flex-1 p-ds-300">
<Text tone="subtle">Shown from 1024px up. Pass storageKey to remember the choice between visits.</Text>
</div>
</div>
);
}Guidelines
When to use it
- Navigating an app with several sections.
Use something else when
- A public site with few pages. Navbar
Accessibility
Keyboard
| Keys | What happens |
|---|---|
| Tab | Moves 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
| Prop | Type | Default | Description |
|---|---|---|---|
brand | React.ReactNode | – | The product name, after |
logo | React.ReactNode | – | The app's mark (an Icon or an image) before |
brandHref | string | – | |
items | readonly SidebarItemData[] | – | The top-level items (links, or groups with |
children | React.ReactNode | – | With no |
sections | readonly SidebarSectionData[] | – | Labelled sections under |
currentKey | string | – | The id of the page's item: marked |
footer | React.ReactNode | – | The account at the bottom: name and role after |
avatar | React.ReactNode | – | The account's Avatar before |
isFooterPinned | boolean | – | Keeps the account ( |
isCollapsed | boolean | – | Icons only (56px), labels in tooltips. Controlled; or |
defaultCollapsed | boolean | – | |
onCollapsedChange | (isCollapsed: boolean) => void | – | |
storageKey | string | – | Remembers the collapsed choice in localStorage under this key. Render |
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 | – |
|
brandReact.ReactNodeThe product name, after
logo(or the logo and name together). It links tobrandHref. Or aSidebarHeaderchild.logoReact.ReactNodeThe 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 ofbrand.brandHrefstringitemsreadonly SidebarItemData[]The top-level items (links, or groups with
children); five to eight is the comfortable range. Withsections, these are the unlabelled items above the labelled sections (a dashboard) and may be empty. Ids are unique acrossitemsandsections(a repeated id marks two items as the current page). Leave it out to compose the navigation as children instead.childrenReact.ReactNodeWith no
items: the navigation composed fromSidebarItem,SidebarSubmenuandSidebarSection(loose items first, then the sections), plus an optionalSidebarHeader(instead ofbrand) andSidebarFooter(instead offooter).sectionsreadonly 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.currentKeystringThe id of the page's item: marked
aria-current="page"; its group stays open.footerReact.ReactNodeThe account at the bottom: name and role after
avatar(or Avatar, name and role together). Or aSidebarFooterchild.avatarReact.ReactNodeThe account's Avatar before
footer. Collapsed, the rail shows it alone, centred, andfooteris hidden. Without it, collapsed shows the start offooter.isFooterPinnedbooleanKeeps the account (
footer) and the collapse toggle in view at the bottom: the brand stays at the top and only the navigation (items, thensections) 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.isCollapsedbooleanIcons only (56px), labels in tooltips. Controlled; or
defaultCollapsed+onCollapsedChange.defaultCollapsedbooleanonCollapsedChange(isCollapsed: boolean) => voidstorageKeystringRemembers the collapsed choice in localStorage under this key. Render
sidebarScript(storageKey, { defaultCollapsed })in <head> as well, with the samedefaultCollapsed, so the first frame already has the remembered width (no layout jump). Uncontrolled only: withisCollapsedthe app owns the state.isMobileOpenbooleanUnder 1024px the sidebar is a menu panel from the start edge; the app's menu button opens it.
onMobileOpenChange(isOpen: boolean) => voidaria-labelstringNames the navigation landmark; "Main menu" by default.
motionComponentMotionauto(follow the device),reduceornone, for this component; the provider's setting otherwise.
SidebarHeader
| Prop | Type | Default | Description |
|---|---|---|---|
children | React.ReactNode | – | The product name (or the logo and name together); it links to the Sidebar's |
logo | React.ReactNode | – | The app's mark before the name; collapsed, the rail shows it alone. As the Sidebar's |
childrenReact.ReactNodeThe product name (or the logo and name together); it links to the Sidebar's
brandHref.logoReact.ReactNodeThe app's mark before the name; collapsed, the rail shows it alone. As the Sidebar's
logo.
SidebarItem
| Prop | Type | Default | Description |
|---|---|---|---|
idRequired | string | – | Unique in the sidebar; |
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 |
idRequiredstringUnique in the sidebar;
currentKeymatches it.labelRequiredstringA noun for the page ("Orders"); also the tooltip when the sidebar is collapsed.
iconIconNameLucide name; top-level items carry one (it is all a collapsed sidebar shows).
hrefstringbadge{ value: number; tone?: BadgeCountTone | undefined; }A count ("4 new"): a Badge after the label, on the icon when collapsed.
isCurrentbooleanMarks this item as the page in view, instead of the Sidebar's
currentKey.
SidebarSection
| Prop | Type | Default | Description |
|---|---|---|---|
id | string | – | Also on the DOM as |
labelRequired | string | – | The overline over the items, already translated; it names the group, also when collapsed. |
childrenRequired | React.ReactNode | – |
|
idstringAlso on the DOM as
data-section.labelRequiredstringThe overline over the items, already translated; it names the group, also when collapsed.
childrenRequiredReact.ReactNodeSidebarItems andSidebarSubmenus.