Prepared Docs

Prepared Docs

⌘K

    Loading navigation…

User

  1. Blocks
  2. Drawer Host
  3. API and Development

Drawer host

API and Development

View Source
Submit Issue

Import

Load Drawer's styles.css as well. The host has no stylesheet of its own.

DrawerHost

NameRequiredDescription
drawersyesDrawers the host can show. Each has id, title, and content.
closeLabelyesAccessible name of the close control.
openwith drawerIdWhether the drawer is shown. Omit when store is set.
drawerIdwith openId to show. null shows nothing.
onOpenChangewith openRequested open state and cancelable details.
storeinstead of openStore from createDrawerHostStore.
triggernoOne Button that opens the drawer.
onExitCompletenoCalled once when the close animation has finished.

Drawer entry

NameDescription
idValue the shell stores as drawerId.
titleHeader heading and accessible name.
contentScrolling body.
edgeDrawerEdge. Default InlineEnd.
sizeDrawerSize. Default Medium.
placementDrawerPlacement. Default Viewport.
resizeLabelNames the resize handle. Omit it for a fixed size.
scrollRegionLabelName of the body scroll region.
nav{ label, items, value?, defaultValue?, onValueChange? }.

createDrawerHostStore

createDrawerHostStore({ open?, drawerId? }) returns { getState, subscribe, open(id), close }. close leaves the id set so the panel can finish closing. open(id) replaces the drawer that is open.

Replacing @prepared911/ui-drawer

OldNew
DrawerPortalDo not mount a portal node. Drawer mounts through Portal into the trigger's document.
useDrawerStore / setDrawerOpenopen and onOpenChange, or store.open / store.close.
AppDrawer / useAppDrawerStoreDrawerHost and the shell's id.
AnchorPosition.Right / LeftDrawerEdge.InlineEnd / InlineStart.
width, minWidth, maxWidthDrawerSize.Medium, Small, Large.
DrawerNav childrennav on the drawer entry.
closeTitlecloseLabel.
onCloseonOpenChange when open is false.

The shell's drawer search param stays shell-owned. This host does not read it.

Previous

Drawer host / Usage

Next

Drawer host / Accessibility

On this page

Import
DrawerHost
Drawer entry
createDrawerHostStore
Replacing @prepared911/ui-drawer