Admin Sidebar

admin-sidebar

Module-tier shell sidebar — owns resize, snap-to-collapsed, persistence, and the [collapsed] reflected attribute. Sits inside <admin-shell> as slot="leading" or slot="trailing". Authors compose chrome bars + content inside via slot vocabulary.

Basic shape

Drop into <admin-shell> as a slotted child. Add resizable to wire the drag handle, collapsible to wire programmatic collapse.

<admin-sidebar slot="leading" resizable collapsible> <admin-topbar slot="header">…</admin-topbar> <nav-ui>…</nav-ui> <admin-statusbar slot="footer">…</admin-statusbar> <div data-resize></div> </admin-sidebar>

State as attribute

The sidebar reflects its state on the element itself — no data-* proxy attributes, no threshold math from the outside.

AttributeWhen setUse for
collapsedWidth is at or below 96px (snap floor)CSS :has(admin-sidebar[collapsed]) selectors; JS .hasAttribute('collapsed')
resizingActive pointer-dragSuppress transitions during drag

The reflection is round-tripped — set collapsed programmatically and the sidebar will width-snap; release the attribute and it expands to the previously-saved width.

Public methods

MethodEffect
.toggle()Flip collapsed state. Returns the new collapsed value.
.collapse()Force collapsed (idempotent if already collapsed).
.expand()Restore the previous expanded width.

Events

EventDetail
sidebar-toggle{ name, expanded } — bubbles when collapsed/expanded
sidebar-resize{ name, width } — bubbles after a pointer-drag releases

Properties

PropTypeDefaultDescription
resizablebooleanfalseOpts in to drag-to-resize. Author supplies a child [data-resize] element.
collapsiblebooleanfalseOpts in to .toggle()/.collapse()/.expand().
namestring(slot value)localStorage namespace override.
min-widthstring(CSS min-width)Override for the snap-floor width.
collapsedbooleanReflected — set when width ≤ 96px.
resizingbooleanReflected — set during active drag.

Persistence

Width is saved to localStorage on every drag release + every toggle, under the key adia-sidebar-{name} (where name defaults to the slot value). On reconnect, the saved width is restored — the “previous expanded width” tracker preserves the user's preferred expanded size across collapse cycles.