# Sidebar (@limerdev/zest) An app's layout with a navigation panel: `` (`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.Group`s, each named by a `Sidebar.GroupLabel` and holding a `Sidebar.Menu` of `Sidebar.MenuItem`s, 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 ``, 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. - Category: Layout - Import: `import { Sidebar } from '@limerdev/zest'` - Exports: `Sidebar.Root`, `Sidebar.Panel`, `Sidebar.Header`, `Sidebar.Content`, `Sidebar.Footer`, `Sidebar.Group`, `Sidebar.GroupLabel`, `Sidebar.Menu`, `Sidebar.MenuItem`, `Sidebar.MenuButton`, `Sidebar.MenuBadge`, `Sidebar.Trigger`, `Sidebar.Inset` - 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`. ```svelte Acme Billing Billing 12
{@render children()}
``` Props of `Sidebar.Root`: - `collapsible` (`"none" | "icon" | "offcanvas"`, default `'offcanvas'`): How the panel collapses on a wide screen: off the screen (`offcanvas`), to its icons (`icon`), or not at all (`none`). - `open` (`boolean`, default `true`, bindable): Whether the panel is expanded on a wide screen. - `openMobile` (`boolean`, default `false`, bindable): Whether the panel's sheet is open on a small screen. Props of `Sidebar.Panel`: - `label` (`string`, default `the Config's `strings.sidebar`, else 'Sidebar'`): The name of the panel's sheet on a small screen. Props of `Sidebar.Content`: - `label` (`string`, default `the Config's `strings.mainNavigation`, else 'Main'`): The name of the navigation landmark. Props of `Sidebar.MenuButton`: - `active` (`boolean`, default `false`): Marks the current page: `aria-current="page"` and the active look. The app knows its route and passes it. Props of `Sidebar.Trigger`: - `label` (`string`, default `the Config's `strings.toggleSidebar`, else 'Toggle sidebar'`): The button's name for screen readers. - `size` (`"default" | "sm" | "lg" | "icon" | "icon-sm" | "icon-lg"`, default `'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"`, default `'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. Example: 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. ```svelte
Acme Billing {#each sections as section (section.label)} {section.label} {#each section.pages as item (item.href)} { event.preventDefault(); current = item.href; }} > {#if item.count} {item.count} {/if} {/each} {/each}
{sections.flatMap((section) => section.pages).find((p) => p.href === current)?.label}
The page.
```