Sidebar

Layout

An app's layout with a navigation panel: <Sidebar.Root> (bind:open, collapsible: offcanvas by default, icon or none) holds a Sidebar.Panel and a Sidebar.Inset (the page, main), where a Sidebar.Trigger shows and hides the panel. The panel has a Sidebar.Header, a Sidebar.Content (a navigation landmark, label) of Sidebar.Groups, each named by a Sidebar.GroupLabel and holding a Sidebar.Menu of Sidebar.MenuItems, and a Sidebar.Footer. A Sidebar.MenuButton is a link with href (a button without); active marks the current page, which the app passes from its router; its text goes in a <span>, hidden but still read when the panel collapses to icons; a Sidebar.MenuBadge shows a count. Below the md breakpoint the panel is a sheet from the left (bind:openMobile) that closes when a page is chosen.

import { Sidebar } from '@limerdev/zest';
Sidebar for AI tools (llms.txt)
Use for
The frame of an admin app: its sections and pages, the workspace and the user.
Don't
A few pages: links in a header (NavigationMenu). Tabs within one page: use Tabs. A panel of details or a form: use Sheet.

Examples

App frame

An app frame that collapses to icons. In an app it fills the screen; here it is sized to fit the preview. active comes from the app's router.

Invoices
The page.

Props

Every part also takes class (merged over its defaults), ref (bindable: the element), children, and child (a snippet that renders your own element, with props to spread on it).

Sidebar.Root

Prop Type Default Description
collapsible "none" | "icon" | "offcanvas" 'offcanvas' How the panel collapses on a wide screen: off the screen (offcanvas), to its icons (icon), or not at all (none).
open bindable boolean true Whether the panel is expanded on a wide screen.
openMobile bindable boolean false Whether the panel's sheet is open on a small screen.

Sidebar.Panel

Prop Type Default Description
label string the Config's `strings.sidebar`, else 'Sidebar' The name of the panel's sheet on a small screen.

Sidebar.Header

No props of its own beyond the common ones.

Sidebar.Content

Prop Type Default Description
label string the Config's `strings.mainNavigation`, else 'Main' The name of the navigation landmark.

Sidebar.Footer

No props of its own beyond the common ones.

Sidebar.Group

No props of its own beyond the common ones.

Sidebar.GroupLabel

No props of its own beyond the common ones.

Sidebar.Menu

No props of its own beyond the common ones.

Sidebar.MenuItem

No props of its own beyond the common ones.

Sidebar.MenuButton

Prop Type Default Description
active boolean false Marks the current page: aria-current="page" and the active look. The app knows its route and passes it.

Sidebar.MenuBadge

No props of its own beyond the common ones.

Sidebar.Trigger

Prop Type Default Description
label string the Config's `strings.toggleSidebar`, else 'Toggle sidebar' The button's name for screen readers.
size "default" | "sm" | "lg" | "icon" | "icon-sm" | "icon-lg" 'icon-sm' The height and padding, from the theme's field size; the icon sizes are square.
variant "link" | "primary" | "secondary" | "neutral" | "error" | "outline" | "ghost" 'ghost' The look, by the theme's colour roles: primary for the main action, error for deleting, secondary, neutral and outline for the rest, ghost in toolbars, link for a navigation that looks like text.

Sidebar.Inset

No props of its own beyond the common ones.