Skip to content

GhostDrawer ​

GhostDrawer (also called a Sheet) is an edge-anchored panel built as a GhostDialog variant. It anchors to the start, end, top, or bottom viewport edge and keeps the dialog's focus trapping, dismissal, scroll locking, and background isolation. Use it for DataTable filter panels, row-detail inspectors, and navigation drawers. Import GhostDrawer, GhostDrawerTrigger, GhostDrawerOverlay, GhostDrawerContent, GhostDrawerTitle, GhostDrawerDescription, and GhostDrawerClose from @ghostvue/vue for headless use, or from @ghostvue/themes for the default edge panel, scrim, and slide-in entry.

Themed

Elevation-4 end-side sheet with scrim overlay, slide-in entry, and themed button actions.

Order #4182Shipped
Order #4182 shipped to Lisbon · €148.00

Inspect order opens an end-anchored modal drawer with order details and actions. Importing from @ghostvue/themes loads default.css, which styles .ghost-drawer-overlay with var(--ghost-scrim) and .ghost-drawer-content with --ghost-elevation-4-*, radius, hairline border, inset padding, and focus-ring tokens. Panels slide and fade in with @starting-style.

GhostDrawer defaults to side="end" and modal behavior. Tab loops inside the open panel while the background is inert. Escape dismisses the drawer and returns focus to Inspect order.

Sides and writing direction ​

Sides

Logical start and end side panels plus top and bottom sheets, including an RTL subtree.

start and end are logical. A drawer portaled to <body> cannot inherit the direction of the subtree around its trigger, so GhostDrawerContent resolves it (explicit dir → content ancestor → trigger ancestor → <html dir> → ltr), exposes data-dir="ltr" | "rtl", and sets dir="rtl" on the panel when needed. The theme maps data-side + data-dir to physical left / right edges. top and bottom open as full-width sheets. Set side on GhostDrawer, or override it on GhostDrawerContent. Every part reports the effective side in data-side.

Non-modal drawers ​

Non-modal

Drawer with modal=false: no overlay, scroll lock, or focus trap; the page stays interactive.

:modal="false" removes GhostDrawerOverlay, aria-modal, scroll lock, background inert, and the Tab trap, so the page stays usable. A non-modal drawer open at mount does not steal focus. Clicking another focusable control outside closes the drawer and leaves focus on that control.

Nested overlays ​

Nested

Confirmation dialog stacked above a filter drawer; Escape dismisses only the topmost layer.

Dialogs, popovers, selects, and menus opened inside a drawer stack above it. Escape dismisses only the topmost layer. GhostDrawer uses its own injection key, so GhostDialog parts inside a drawer always bind to their own dialog.

Motion ​

With prefers-reduced-motion: no-preference, panels slide in from their edge and fade in using --ghost-motion-enter-duration and --ghost-motion-enter-easing. With prefers-reduced-motion: reduce, the theme sets translate: none and keeps only a short opacity fade. Closing slides the panel back to its edge over the faster --ghost-motion-exit-duration (a fade only under reduced motion). Focus, scroll lock, and background inert release as soon as it closes, and the panel unmounts when the slide ends (see GhostPresence).

Advanced: headless composition ​

Basic use ​

Basic Headless

Unstyled end-side modal drawer with overlay, trapped Tab focus, scroll lock, and inert background.

Use the headless parts when your application supplies the panel and scrim styles. The example keeps the default end side, dismissal, and focus behavior.

API ​

See the generated component references for props, emits, slots, exposed members, styling hooks, CSS variables, and executable examples.

PropTypeDefaultDescription
defaultOpenbooleanfalseInitial open state when open is omitted.
dirGhostDrawerDirection—Explicit writing direction for mapping logical start / end sides.
modalbooleantrueEnables modal behavior (trapped focus, scroll lock, inert background, overlay).
openboolean—Controlled open state. Omit for uncontrolled mode.
sideGhostDrawerSide"end"Viewport edge the drawer is anchored to ('start', 'end', 'top', 'bottom').
SlotSlot propsDescription
defaultclose: () => void, open: boolean, side: GhostDrawerSideDrawer trigger, overlay, content, title, description, and close parts.

@ghostvue/themes adds no props, events, or slots to the headless GhostDrawer API, which it forwards.

GhostDrawer (root) ​

Props: open, defaultOpen, modal (default true), side (default 'end'), and dir. Emits update:open. The default slot receives { open, close, side }.

GhostDrawerTrigger ​

Sets type="button" (for as="button"), aria-haspopup="dialog", aria-expanded, aria-controls, data-part="trigger", data-state, and data-side.

GhostDrawerOverlay ​

Renders only while open and modal. Sets aria-hidden="true", data-part="overlay", data-state="open", and data-side.

GhostDrawerContent ​

Props: as, side, dir, role, closeOnEscape, closeOnOutsideClick, portal, and portalTo. Sets role, aria-modal="true" (when modal), tabindex="-1", data-part="content", data-state="open", data-side, data-dir, aria-labelledby, and aria-describedby.

GhostDrawerTitle, GhostDrawerDescription, GhostDrawerClose ​

Title and Description register their IDs for aria-labelledby and aria-describedby. Close closes the drawer on click, Enter, or Space. Every part exposes { element, focus, blur }.

useGhostDrawer(options?) and resolveDrawerDir(options?) ​

useGhostDrawer returns { isOpen, isModal, side, dir, open, close, toggle, triggerId, contentId, titleId, descriptionId }. resolveDrawerDir({ dir, contentElement, triggerElement, documentElement }) returns 'ltr' | 'rtl' and is safe to call during SSR.

Accessibility ​

  • Always render GhostDrawerTitle (or pass aria-label / aria-labelledby on GhostDrawerContent); otherwise GHOST002 is logged in development. role="alertdialog" also needs a description (GHOST003).
  • Modal drawers trap focus, mark the background inert, and restore focus to the trigger after closing.
  • Placement and direction are visual only; the drawer is announced as a dialog.
  • In forced-colors mode the panel uses system Canvas / CanvasText colors and a Highlight focus outline.

Specification ​

See GhostDrawer specification, GhostDialog, and ADR 0012: Modal overlays.