Skip to content

Drawer

Reveal focused content from any viewport edge and dismiss it with a directional swipe.

Usage

Bottom

Open a modal surface from the bottom edge and dismiss it by dragging the handle downward.

Open a modal surface from the bottom edge and dismiss it by dragging the handle downward.

Side

Open the same drawer contract from a horizontal viewport edge.

Open the same drawer contract from a horizontal viewport edge.

Controlled

Let the parent own the current value and apply accepted changes back to the component.

Let the parent own the current value and apply accepted changes back to the component.

Outside interaction

closeOnInteractOutside controls whether a pointer interaction outside the content closes it. Elements in interactOutsideExclusions stay interactive in a modal and do not count as outside. For conditional decisions, call preventDefault() from the interact-outside event.

template
<DrawerRoot
  :interact-outside-exclusions="[ignoredElement]"
  @interact-outside="(event) => {
    if (event.isInside(temporarilyIgnoredElement)) event.preventDefault()
  }"
/>

Swipe behavior

Dragging DrawerHandle outward dismisses the drawer. Add data-sectile-drawer-swipe-ignore to descendants such as form controls that must not begin a drag. Style motion and exit states with data-swipe="move|cancel|end", data-swiping, --sectile-drawer-swipe-movement-x, --sectile-drawer-swipe-movement-y, and --sectile-drawer-swipe-progress.

API

Vue package: @sectile/vue/drawer

Components
  • DrawerRoot
  • DrawerTrigger
  • DrawerPortal
  • DrawerOverlay
  • DrawerContent
  • DrawerHandle
  • DrawerTitle
  • DrawerDescription
  • DrawerClose

Props

DrawerRootProps

autoFocus

Whether focus moves into the component when it opens.

closeOnInteractOutside

Whether interaction outside the content closes it.

defaultOpen

Initial uncontrolled open state.

disabled

Whether interaction is unavailable.

initialFocus

Element or resolver that receives focus when the component opens.

interactOutsideExclusions

Elements that stay interactive and do not count as outside interaction.

label

Accessible name announced for the control.

modal

Whether open content blocks interaction with the surrounding page.

open

Whether the associated popup or disclosure is open.

restoreFocus

Whether focus returns to the trigger when open content closes.

side

Viewport edge from which the drawer opens.

swipeThreshold

Pointer travel in pixels required to dismiss by swiping.

swipeToDismiss

Whether an outward pointer swipe may dismiss the drawer.

swipeVelocityThreshold

Outward drag velocity in pixels per millisecond that dismisses the drawer.

trapFocus

Whether keyboard focus stays inside open content.

unmountOnExit

Whether presence-managed content is removed from the DOM after its exit motion completes.

DrawerPartProps

as

Element or component rendered for this part.

asChild

Whether to merge this part into its single child instead of rendering a wrapper.

DrawerPortalProps

defer

Whether Teleport target resolution waits until the end of the current mount or update tick.

disabled

Whether interaction is unavailable.

to

Teleport target for portalled content.

Slots

DrawerRootSlotProps

disabled

Whether interaction is unavailable.

open

Whether the associated popup or disclosure is open.

Other types

DrawerOpenChangeHandler

ts
type DrawerOpenChangeHandler = PopupFactoryOptions['onOpenChange']

DrawerInteractOutsideHandler

ts
type DrawerInteractOutsideHandler = NonNullable<PopupFactoryOptions['onInteractOutside']>

DrawerSide

ts
type DrawerSide = 'top' | 'right' | 'bottom' | 'left'

Parts

Shared scope: [data-scope="drawer"]. Combine it with a part selector to keep styles local to this component.

PartSelectorRoleExtra attributes
trigger[data-part="trigger"]Opens, closes, or activates the associated content.
overlay[data-part="overlay"]Covers surrounding content while a modal surface is open.
content[data-part="content"]Contains the component content shown for the active state.
handle[data-part="handle"]Provides the directional swipe dismissal surface.aria-hidden="true"
title[data-part="title"]Labels the associated content.
description[data-part="description"]Describes the associated content or decision.
close[data-part="close"]Closes or dismisses the current surface.

Keyboard interaction

KeyBehavior
Enter / SpaceActivate the trigger or focused action.
Tab / Shift+TabMove through controls while modal focus remains inside.
EscapeClose the drawer and restore focus when configured.
Pointer swipeDrag the handle outward past the distance or velocity threshold to dismiss.

Accessibility

The drawer follows modal dialog semantics, exposes its edge and swipe direction, and keeps its gesture handle hidden from assistive technology.

See the corresponding WAI-ARIA pattern for the host accessibility contract.

Released under the MIT License.