Sidebar
The side navigation of an app shell: header, content and footer; on wide screens it collapses to an icon rail (or out of view), below a breakpoint it becomes an off-canvas drawer. toggle() does the right thing for the screen. It is for navigation, a list of places with icons; for content such as a tree of documents, a panel that hides and resizes, put your own element in a pane of a ray-split (the start pane, or the end pane with fixed="end" for an inspector; min, max, autosave, collapsed).
API
For AI agents: this API as Markdown, or every component in llms-full.txt.
<ray-sidebar>
Put ray-sidebar-group + ray-nav-link (with an icon in slot=left) inside. Collapsed, nav links show only their icon (the label becomes the tooltip) and the host has the collapsed attribute, so your own header/footer content can hide with CSS (ray-sidebar[collapsed] .brand-name { display: none }).
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
collapsed | collapsed reflects | boolean | Wide screens: collapsed as collapse says (an icon rail, or out of view). | |
collapse | collapse reflects | icon | offcanvas | icon | What collapsed does on wide screens: icon, a rail of the nav links' icons; offcanvas, hidden entirely (no width, out of the tab order). |
open | open reflects | boolean | Narrow screens: the drawer is shown (modal, focus trapped; Escape, backdrop click or a followed link close it). | |
side | side reflects | start | end | left | right | start | The edge it sits on (its border faces the content, its narrow-screen drawer slides from there): start/end follow the writing direction; left/right are sides of the screen. |
variant | variant reflects | sidebar | floating | sidebar | A panel against the edge, or a floating card with a margin. |
width | width | string | Width when expanded (CSS length). Default 16rem. | |
collapsedWidth | collapsed-width | string | Width of the icon rail. Default 3.5rem. | |
breakpoint | breakpoint | string | 48em | At this viewport width and below, it becomes a drawer. |
label | label | string | Sidebar (text sidebar.label) | Accessible name of its navigation. |
resizable | resizable reflects | boolean | Wide screens, expanded: its inner edge drags (or, focused, arrow-keys; Shift is faster, Home/End go to the limits) the width between min-width and max-width. | |
minWidth | min-width | number | 192 | Narrowest width when resizing, in px. |
maxWidth | max-width | number | 480 | Widest width when resizing, in px. |
autosave | autosave | string | A key: the resized width is saved in localStorage and restored. A later change of width wins. | |
resizeLabel | resize-label | string | Resize sidebar (text sidebar.resize) | Accessible name of the resize edge. |
| Event | Description |
|---|---|
ray-resize | After a drag or a key resized it (resizable). |
ray-toggle | After toggle(). |
ray-open | The drawer opened (narrow screens). |
ray-close | The drawer closed (narrow screens). |
| Slot | Description |
|---|---|
| (default) | The navigation: ray-sidebar-group and ray-nav-link elements. |
header | Top area (brand, workspace switcher). |
footer | Bottom area (user, settings). |
| Part | Description |
|---|---|
panel | The panel (in the drawer on narrow screens). |
header | The header area. |
content | The scrolling <nav>. |
footer | The footer area. |
resizer | The resize edge (a separator), shown when resizable. |
drawer | The <dialog> used on narrow screens. |
<ray-sidebar-group>
A titled section of nav links; the title fades out (keeping its height) when the sidebar collapses.
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
label | label | string | Section title. |
| Slot | Description |
|---|---|
| (default) | ray-nav-link elements. |
| Part | Description |
|---|---|
label | The title. |
items | The links container. |
Texts
What it writes itself, in English; setStrings() translates them (Getting started: Languages).
| Key | English |
|---|---|
sidebar.label | Sidebar |
sidebar.resize | Resize sidebar |