DesignOverviewDesign SystemMapsGraphIntroductionInstallationDeriving a themeSandboxTheme builderVisual testingAgentsCortexMemoryActiveProvenanceActiveContextActiveServicesInsightsGet in touchSource on GitHub
Loading the reference
DrawerView sourceEdit in SandboxView MarkdownCopy MarkdownOpen in ClaudeOpen in CursorA panel that slides in from an edge.Also called Sheet, Sidebar, Panel, and Off-canvas.StableSince 0.1.0OverlaysImportimport'@fusion.dev/helix/drawer'import'@fusion.dev/helix-headless/drawer'Preview
GuidelinesWhen to use
Details, filters, or navigation that slide in from an edge, with the page still in view.DrawerThis page
Open the drawer from a button with commandfor="<id>" naming the drawer and command="--show".The platform's invoker attributes open it with no script.<helix-buttoncommand="--show"commandfor="note"emphasis="solid"tone="primary">
Write a note
</helix-button><helix-drawerid="note"label="Note"placement="bottom"><spanslot="header">Note</span><helix-textareaid="note-text"label="Note"placeholder="Type, then drag the sheet down"></helix-textarea><helix-buttonemphasis="solid"id="note-save"slot="footer"tone="primary">
Save
</helix-button></helix-drawer><scripttype="module">constnote=document.getElementById('note')consttext=document.getElementById('note-text')letsaved=''// An unsaved note keeps the sheet open, however it is asked to close.note.addEventListener('helix-before-close',(event)=>{if(text.value!==saved){event.preventDefault()}})document.getElementById('note-save').addEventListener('click',()=>{saved=text.valuenote.close()})</script>
Anatomy
1::part(panel)The sliding panel.
2::part(header)The header region.
3::part(dismiss)OptionalThe close control, drawn when the drawer is dismissible, in the corner by the title.
4::part(content)The scrolling content region.
API referenceRoothelix-drawerA panel that slides in from an edge.
PropTypeDescriptionclosedBy"any"|"closerequest"|"none"Which close requests the browser handles on its own.defaultOpenbooleanDefaultfalseWhether the element starts open. Ignored once open is written.dismissiblebooleanDefaultfalseDraws a control that closes the drawer, in the corner where the title is.dismissLabelstringDefault"Close"The close control's accessible name. Translate it with the rest of your
interface.fallbackLabelstringDefault"Drawer"The panel's name where nothing names it: no label, no heading in the
header slot, and no aria-labelledby on the host.labelstringDefault""Accessible name for the panel. When it is empty, the heading in the
header slot names the panel.material"frosted"|"glass"Makes the panel translucent, as frosted or glass. When it is not set,
the panel is opaque.modalbooleanDefaulttrueWhether the drawer blocks the page behind it.openbooleanWhether the element is open.persistentbooleanDefaultfalseStops Escape, a press outside, and a swipe from closing the drawer, for a
drawer that has to be answered.placement"start"|"end"|"top"|"bottom"Which edge the drawer comes from.returnValuestringWhat the dialog closed with, the way <dialog> reports it.snapPointsstringDefault""The fractions of the panel a reader can leave on screen, as a list such as
0.5 1. The drawer opens at the smallest, and a swipe comes to rest at the
nearest, or closes the drawer below the smallest.swipebooleanDefaulttrueWhether a touch or a pen can swipe the drawer away. swipe="false" turns
it off, for a panel whose content has its own use for the gesture, such as
a map.
ReadTypeDescriptionsnapnumberThe fraction of the panel on screen at the snap point it rests at, such as
0.5. It is 1, the whole panel, while the drawer is closed or has no
snap-points.whenSettledPromise<void>Resolves a frame after the first update, when transitions are switched on.
SlotDescription(default)The drawer's content.dismiss-iconReplaces the glyph inside the close control.footerContent pinned below the scrolling area, such as the drawer's actions. Write the action that dismisses first and the primary one last.headerContent pinned above the scrolling area.
EventTypeDescriptioncloseEventSent from the host after the drawer closes, because the native close event does not leave the shadow root.helix-before-closeHelixBeforeCloseEventFired before the panel closes, and cancelable.helix-before-openHelixBeforeOpenEventFired before the panel opens, and cancelable. Canceling it keeps the panel closed.toggleToggleEventSent when the drawer opens or closes, with newState and oldState.
MethodTypeDescriptionclose(returnValue: string) => voidRequests that the drawer close, and takes what it closed with, the way
Dialog.close(value) does. A helix-before-close listener can refuse it,
and then the value is not kept.requestOpen(next: boolean) => booleanRequests that the element open or close, and returns whether the change
was applied.show() => voidOpens the drawer.snapTo(point: number) => voidMoves the open panel to rest at the snap point nearest point, a fraction
of the panel such as 1 for the whole of it.toggleOpen() => booleanRequests the opposite of the current state.
PartDescriptioncontentThe scrolling content region.dismissThe close control, drawn when the drawer is dismissible, in the corner by the title.dismiss-markThe glyph on the close control, where none is slotted.footerThe footer region.headerThe header region.panelThe sliding panel.
CSS PropertyDescription--drawer-backdropFilter applied behind a frosted or glass drawer. Follows the theme's material policy. Set it to change the strength on one drawer.--drawer-background-colorSurface behind the panel.--drawer-border-colorColor of the panel's edge.--drawer-border-widthWidth of the panel's edge. Follows --helix-border-floating, a hairline, so the panel has an edge as well as its shadow over a dark page. Set it to 0 for the shadow alone.--drawer-drag-progressHow far a drag, and the glide after it, has taken the panel from its smallest snap point to off its edge, from 0 to 1. Written only while the host has :state(dragging).--drawer-paddingPadding inside the panel.--drawer-padding-block-startPadding above the header. It is one step larger than the other three sides, so the first line clears the window's edge. Falls back to --drawer-padding, so setting that alone sets all four sides.--drawer-radiusCorner radius on the edges that face the page.--drawer-release-durationThe longest a released panel takes to go off its edge, or to go back to rest. Defaults to --helix-duration-slow. 0ms lands it at once.--drawer-release-easingThe curve a released panel goes back to rest along. Defaults to --helix-easing-spring.--drawer-scrimThe tint over the page behind the drawer. Set it on the host, because a var() written inside ::backdrop cannot read a token.--drawer-shadowShadow under the panel. Follows --helix-shadow-floating. A floating surface can sit over any content, so it has a shadow by default.--drawer-sizeWidth or height of the panel.--drawer-swipe-xHow far the snap point the panel rests at moves it across, in pixels, toward the right.--drawer-swipe-yHow far the snap point the panel rests at moves it down, in pixels.
Custom stateDescriptiondraggingFrom the moment a finger starts dragging the panel until its release has come to rest, on screen or off it.enteringFrom the moment the drawer opens until its entrance has finished.exitingFrom the moment the drawer closes until its exit has finished.openWhile the drawer is open.settledSet one frame after the first render. Transitions wait for it, so an element does not animate its own arrival.snappedWhile the panel rests at a snap point that shows less than the whole panel.
Roothelix-headless-drawerA panel that slides in from an edge.
PropTypeDescriptionclosedBy"any"|"closerequest"|"none"Which close requests the browser handles on its own.defaultOpenbooleanDefaultfalseWhether the element starts open. Ignored once open is written.dismissiblebooleanDefaultfalseDraws a control that closes the drawer, in the corner where the title is.dismissLabelstringDefault"Close"The close control's accessible name. Translate it with the rest of your
interface.fallbackLabelstringDefault"Drawer"The panel's name where nothing names it: no label, no heading in the
header slot, and no aria-labelledby on the host.labelstringDefault""Accessible name for the panel. When it is empty, the heading in the
header slot names the panel.modalbooleanDefaulttrueWhether the drawer blocks the page behind it.openbooleanWhether the element is open.persistentbooleanDefaultfalseStops Escape, a press outside, and a swipe from closing the drawer, for a
drawer that has to be answered.placement"start"|"end"|"top"|"bottom"Which edge the drawer comes from.returnValuestringWhat the dialog closed with, the way <dialog> reports it.snapPointsstringDefault""The fractions of the panel a reader can leave on screen, as a list such as
0.5 1. The drawer opens at the smallest, and a swipe comes to rest at the
nearest, or closes the drawer below the smallest.swipebooleanDefaulttrueWhether a touch or a pen can swipe the drawer away. swipe="false" turns
it off, for a panel whose content has its own use for the gesture, such as
a map.
ReadTypeDescriptionsnapnumberThe fraction of the panel on screen at the snap point it rests at, such as
0.5. It is 1, the whole panel, while the drawer is closed or has no
snap-points.whenSettledPromise<void>Resolves a frame after the first update, when transitions are switched on.
SlotDescription(default)The drawer's content.dismiss-iconReplaces the glyph inside the close control.footerContent pinned below the scrolling area, such as the drawer's actions. Write the action that dismisses first and the primary one last.headerContent pinned above the scrolling area.
EventTypeDescriptioncloseEventSent from the host after the drawer closes, because the native close event does not leave the shadow root.helix-before-closeHelixBeforeCloseEventFired before the panel closes, and cancelable.helix-before-openHelixBeforeOpenEventFired before the panel opens, and cancelable. Canceling it keeps the panel closed.toggleToggleEventSent when the drawer opens or closes, with newState and oldState.
MethodTypeDescriptionclose(returnValue: string) => voidRequests that the drawer close, and takes what it closed with, the way
Dialog.close(value) does. A helix-before-close listener can refuse it,
and then the value is not kept.requestOpen(next: boolean) => booleanRequests that the element open or close, and returns whether the change
was applied.show() => voidOpens the drawer.snapTo(point: number) => voidMoves the open panel to rest at the snap point nearest point, a fraction
of the panel such as 1 for the whole of it.toggleOpen() => booleanRequests the opposite of the current state.
PartDescriptioncontentThe scrolling content region.dismissThe close control, drawn when the drawer is dismissible.dismiss-markThe glyph on the close control, where none is slotted.footerThe footer region.headerThe header region.panelThe sliding panel.
CSS PropertyDescription--drawer-drag-progressHow far a drag, and the glide after it, has taken the panel from its smallest snap point to off its edge, from 0 to 1. Written only while the host has :state(dragging).--drawer-release-durationThe longest a released panel takes to go, or to go back to rest. Unset, it lands at once.--drawer-release-easingThe curve a released panel goes back to rest along, with the speed it was let go carried in.--drawer-swipe-xHow far the snap point the panel rests at moves it across, in pixels, toward the right.--drawer-swipe-yHow far the snap point the panel rests at moves it down, in pixels.
Custom stateDescriptiondraggingFrom the moment a finger starts dragging the panel until its release has come to rest, on screen or off it.enteringFrom the moment the drawer opens until its entrance has finished.exitingFrom the moment the drawer closes until its exit has finished.openWhile the drawer is open.settledSet one frame after the first render. Transitions wait for it, so an element does not animate its own arrival.snappedWhile the panel rests at a snap point that shows less than the whole panel.
Examples
NameDescriptionEventsThe four events a drawer sends: helix-before-open, helix-before-close, toggle, and the native close.MaterialA glass drawer, which shows the page behind it through its own scrim.PlacementsA drawer from each of the four edges.PreviewA panel that slides in from an edge, opened by a button.PreviewA panel that slides in from an edge, opened by a button.SheetA bottom sheet that rests half open, with its actions in the footer. Drag it up to open it fully. Drag it down past halfway, or flick it down, to close it.UnsavedA sheet that stays open while its note has unsaved changes. Drag it down and it springs back, because the page refuses helix-before-close. Save the note to close it.