UI

Drawer

A side or bottom surface that holds a short task without leaving the screen.

Read Markdown

Web 0.2.0

  • Defaultlight16.03 : 1AA 4.5dark4.90 : 1AA 4.5
  • KeyboardEnterSpaceTabShift+TabEscape
  • measured on 0.2.0
npx shadcn@latest add @maeso/drawer
Size
93.2 kB gzipmeasured on 0.2.0

Usage

Control the open state and choose the supporting panel's side. Supply a title and an explicit dismissal handler when dismissal is allowed.

Accessibility

Keep the panel labelled and preserve focus handling. Dismissible drawers need a keyboard close path and focus return.

When to use

Use for supporting detail beside the current task. Use Dialog for a compact interrupting decision.

Install

Add this registry to your project's components.json once, before the first install. Keep your existing settings and other registries.

{
  "registries": {
    "@maeso": "http://127.0.0.1:4321/r/{name}.json"
  }
}

Then install the registry's default theme once, and import its sheet in the CSS entry that imports Tailwind. It paints every item from this registry.

npx shadcn@latest add @maeso/maeso
@import "./styles/theme.web.css";
npx shadcn@latest add @maeso/drawer

Props

Drawer

PropTypeRequiredDescription
actionsReactNodenoControls on one row above the title, such as a pager, left of the close control.
bodyFlushboolean | undefinednoThe body scrolls as one or hands its height to the content, which owns the scroll.
childrenReactNodeno
classNamestring | undefinednoReaches the panel, merged with its own classes rather than replacing them.
descriptionReactNodeno
flushboolean | undefinednoA sheet that owns its whole edge; the floating inset is dropped.
footerReactNodeno
headReactNodenoDrawn instead of the default head; the title still names the panel for assistive technology.
initialFocusRefObject<HTMLElement | null> | undefinednoThe element that takes the cursor on open; the first tabbable one when omitted.
onClose(() => void) | undefinedno
openboolean | undefinedno
scrimboolean | undefinednoOff, the panel is non-blocking and the work behind it stays reachable.
styleCSSProperties | undefinedno
titleReactNodeno
titleHiddenboolean | undefinednoNames the panel for assistive technology without drawing a head, for a body that has its own.
triggerReactElement<unknown, string | JSXElementConstructor<any>> | undefinednoThe control that opens the panel, rendered as the primitive's own trigger.
widthstring | number | undefinedno
Also accepts every HTMLElement attribute275 props
PropTypeRequiredDescription
aboutstring | undefinedno
accessKeystring | undefinedno
aria-activedescendantstring | undefinednoIdentifies the currently active element when DOM focus is on a composite widget, textbox, group, or application.
aria-atomicBooleanish | undefinednoIndicates whether assistive technologies will present all, or only parts of, the changed region based on the change notifications defined by the aria-relevant attribute.
aria-autocomplete"both" | "inline" | "list" | "none" | undefinednoIndicates whether inputting text could trigger display of one or more predictions of the user's intended value for an input and specifies how predictions would be presented if they are made.
aria-braillelabelstring | undefinednoDefines a string value that labels the current element, which is intended to be converted into Braille.
aria-brailleroledescriptionstring | undefinednoDefines a human-readable, author-localized abbreviated description for the role of an element, which is intended to be converted into Braille.
aria-busyBooleanish | undefinedno
aria-checked"false" | "mixed" | "true" | boolean | undefinednoIndicates the current "checked" state of checkboxes, radio buttons, and other widgets.
aria-colcountnumber | undefinednoDefines the total number of columns in a table, grid, or treegrid.
aria-colindexnumber | undefinednoDefines an element's column index or position with respect to the total number of columns within a table, grid, or treegrid.
aria-colindextextstring | undefinednoDefines a human readable text alternative of aria-colindex.
aria-colspannumber | undefinednoDefines the number of columns spanned by a cell or gridcell within a table, grid, or treegrid.
aria-controlsstring | undefinednoIdentifies the element (or elements) whose contents or presence are controlled by the current element.
aria-current"date" | "false" | "location" | "page" | "step" | "time" | "true" | boolean | undefinednoIndicates the element that represents the current item within a container or set of related elements.
aria-describedbystring | undefinednoIdentifies the element (or elements) that describes the object.
aria-descriptionstring | undefinednoDefines a string value that describes or annotates the current element.
aria-detailsstring | undefinednoIdentifies the element that provides a detailed, extended description for the object.
aria-disabledBooleanish | undefinednoIndicates that the element is perceivable but disabled, so it is not editable or otherwise operable.
aria-dropeffect"copy" | "execute" | "link" | "move" | "none" | "popup" | undefinednoIndicates what functions can be performed when a dragged object is released on the drop target.
aria-errormessagestring | undefinednoIdentifies the element that provides an error message for the object.
aria-expandedBooleanish | undefinednoIndicates whether the element, or another grouping element it controls, is currently expanded or collapsed.
aria-flowtostring | undefinednoIdentifies the next element (or elements) in an alternate reading order of content which, at the user's discretion, allows assistive technology to override the general default of reading in document source order.
aria-grabbedBooleanish | undefinednoIndicates an element's "grabbed" state in a drag-and-drop operation.
aria-haspopup"dialog" | "false" | "grid" | "listbox" | "menu" | "tree" | "true" | boolean | undefinednoIndicates the availability and type of interactive popup element, such as menu or dialog, that can be triggered by an element.
aria-hiddenBooleanish | undefinednoIndicates whether the element is exposed to an accessibility API.
aria-invalid"false" | "grammar" | "spelling" | "true" | boolean | undefinednoIndicates the entered value does not conform to the format expected by the application.
aria-keyshortcutsstring | undefinednoIndicates keyboard shortcuts that an author has implemented to activate or give focus to an element.
aria-labelstring | undefinednoDefines a string value that labels the current element.
aria-labelledbystring | undefinednoIdentifies the element (or elements) that labels the current element.
aria-levelnumber | undefinednoDefines the hierarchical level of an element within a structure.
aria-live"assertive" | "off" | "polite" | undefinednoIndicates that an element will be updated, and describes the types of updates the user agents, assistive technologies, and user can expect from the live region.
aria-modalBooleanish | undefinednoIndicates whether an element is modal when displayed.
aria-multilineBooleanish | undefinednoIndicates whether a text box accepts multiple lines of input or only a single line.
aria-multiselectableBooleanish | undefinednoIndicates that the user may select more than one item from the current selectable descendants.
aria-orientation"horizontal" | "vertical" | undefinednoIndicates whether the element's orientation is horizontal, vertical, or unknown/ambiguous.
aria-ownsstring | undefinednoIdentifies an element (or elements) in order to define a visual, functional, or contextual parent/child relationship between DOM elements where the DOM hierarchy cannot be used to represent the relationship.
aria-placeholderstring | undefinednoDefines a short hint (a word or short phrase) intended to aid the user with data entry when the control has no value. A hint could be a sample value or a brief description of the expected format.
aria-posinsetnumber | undefinednoDefines an element's number or position in the current set of listitems or treeitems. Not required if all elements in the set are present in the DOM.
aria-pressed"false" | "mixed" | "true" | boolean | undefinednoIndicates the current "pressed" state of toggle buttons.
aria-readonlyBooleanish | undefinednoIndicates that the element is not editable, but is otherwise operable.
aria-relevant"additions" | "additions removals" | "additions text" | "all" | "removals" | "removals additions" | "removals text" | "text" | "text additions" | "text removals" | undefinednoIndicates what notifications the user agent will trigger when the accessibility tree within a live region is modified.
aria-requiredBooleanish | undefinednoIndicates that user input is required on the element before a form may be submitted.
aria-roledescriptionstring | undefinednoDefines a human-readable, author-localized description for the role of an element.
aria-rowcountnumber | undefinednoDefines the total number of rows in a table, grid, or treegrid.
aria-rowindexnumber | undefinednoDefines an element's row index or position with respect to the total number of rows within a table, grid, or treegrid.
aria-rowindextextstring | undefinednoDefines a human readable text alternative of aria-rowindex.
aria-rowspannumber | undefinednoDefines the number of rows spanned by a cell or gridcell within a table, grid, or treegrid.
aria-selectedBooleanish | undefinednoIndicates the current "selected" state of various widgets.
aria-setsizenumber | undefinednoDefines the number of items in the current set of listitems or treeitems. Not required if all elements in the set are present in the DOM.
aria-sort"ascending" | "descending" | "none" | "other" | undefinednoIndicates if items in a table or grid are sorted in ascending or descending order.
aria-valuemaxnumber | undefinednoDefines the maximum allowed value for a range widget.
aria-valueminnumber | undefinednoDefines the minimum allowed value for a range widget.
aria-valuenownumber | undefinednoDefines the current value for a range widget.
aria-valuetextstring | undefinednoDefines the human readable text alternative of aria-valuenow for a range widget.
autoCapitalize"characters" | "none" | "off" | "on" | "sentences" | "words" | (string & {}) | undefinedno
autoCorrectstring | undefinedno
autoFocusboolean | undefinedno
autoSavestring | undefinedno
colorstring | undefinedno
contentstring | undefinedno
contentEditable"inherit" | "plaintext-only" | Booleanish | undefinedno
contextMenustring | undefinedno
dangerouslySetInnerHTML{ __html: string | TrustedHTML; } | undefinedno
datatypestring | undefinedno
defaultCheckedboolean | undefinedno
defaultValuestring | number | readonly string[] | undefinedno
dirstring | undefinedno
draggableBooleanish | undefinedno
enterKeyHint"done" | "enter" | "go" | "next" | "previous" | "search" | "send" | undefinedno
exportpartsstring | undefinedno
hiddenboolean | undefinedno
idstring | undefinedno
inertboolean | undefinedno
inlistanyno
inputMode"decimal" | "email" | "none" | "numeric" | "search" | "tel" | "text" | "url" | undefinednoHints at the type of data that might be entered by the user while editing the element or its contents
isstring | undefinednoSpecify that a standard HTML element should behave like a defined custom built-in element
itemIDstring | undefinedno
itemPropstring | undefinedno
itemRefstring | undefinedno
itemScopeboolean | undefinedno
itemTypestring | undefinedno
langstring | undefinedno
noncestring | undefinedno
onAbortReactEventHandler<HTMLElement> | undefinedno
onAbortCaptureReactEventHandler<HTMLElement> | undefinedno
onAnimationEndAnimationEventHandler<HTMLElement> | undefinedno
onAnimationEndCaptureAnimationEventHandler<HTMLElement> | undefinedno
onAnimationIterationAnimationEventHandler<HTMLElement> | undefinedno
onAnimationIterationCaptureAnimationEventHandler<HTMLElement> | undefinedno
onAnimationStartAnimationEventHandler<HTMLElement> | undefinedno
onAnimationStartCaptureAnimationEventHandler<HTMLElement> | undefinedno
onAuxClickMouseEventHandler<HTMLElement> | undefinedno
onAuxClickCaptureMouseEventHandler<HTMLElement> | undefinedno
onBeforeInputInputEventHandler<HTMLElement> | undefinedno
onBeforeInputCaptureInputEventHandler<HTMLElement> | undefinedno
onBeforeToggleToggleEventHandler<HTMLElement> | undefinedno
onBlurFocusEventHandler<HTMLElement> | undefinedno
onBlurCaptureFocusEventHandler<HTMLElement> | undefinedno
onCanPlayReactEventHandler<HTMLElement> | undefinedno
onCanPlayCaptureReactEventHandler<HTMLElement> | undefinedno
onCanPlayThroughReactEventHandler<HTMLElement> | undefinedno
onCanPlayThroughCaptureReactEventHandler<HTMLElement> | undefinedno
onChangeChangeEventHandler<HTMLElement, Element> | undefinedno
onChangeCaptureChangeEventHandler<HTMLElement, Element> | undefinedno
onClickMouseEventHandler<HTMLElement> | undefinedno
onClickCaptureMouseEventHandler<HTMLElement> | undefinedno
onCompositionEndCompositionEventHandler<HTMLElement> | undefinedno
onCompositionEndCaptureCompositionEventHandler<HTMLElement> | undefinedno
onCompositionStartCompositionEventHandler<HTMLElement> | undefinedno
onCompositionStartCaptureCompositionEventHandler<HTMLElement> | undefinedno
onCompositionUpdateCompositionEventHandler<HTMLElement> | undefinedno
onCompositionUpdateCaptureCompositionEventHandler<HTMLElement> | undefinedno
onContextMenuMouseEventHandler<HTMLElement> | undefinedno
onContextMenuCaptureMouseEventHandler<HTMLElement> | undefinedno
onCopyClipboardEventHandler<HTMLElement> | undefinedno
onCopyCaptureClipboardEventHandler<HTMLElement> | undefinedno
onCutClipboardEventHandler<HTMLElement> | undefinedno
onCutCaptureClipboardEventHandler<HTMLElement> | undefinedno
onDoubleClickMouseEventHandler<HTMLElement> | undefinedno
onDoubleClickCaptureMouseEventHandler<HTMLElement> | undefinedno
onDragDragEventHandler<HTMLElement> | undefinedno
onDragCaptureDragEventHandler<HTMLElement> | undefinedno
onDragEndDragEventHandler<HTMLElement> | undefinedno
onDragEndCaptureDragEventHandler<HTMLElement> | undefinedno
onDragEnterDragEventHandler<HTMLElement> | undefinedno
onDragEnterCaptureDragEventHandler<HTMLElement> | undefinedno
onDragExitDragEventHandler<HTMLElement> | undefinedno
onDragExitCaptureDragEventHandler<HTMLElement> | undefinedno
onDragLeaveDragEventHandler<HTMLElement> | undefinedno
onDragLeaveCaptureDragEventHandler<HTMLElement> | undefinedno
onDragOverDragEventHandler<HTMLElement> | undefinedno
onDragOverCaptureDragEventHandler<HTMLElement> | undefinedno
onDragStartDragEventHandler<HTMLElement> | undefinedno
onDragStartCaptureDragEventHandler<HTMLElement> | undefinedno
onDropDragEventHandler<HTMLElement> | undefinedno
onDropCaptureDragEventHandler<HTMLElement> | undefinedno
onDurationChangeReactEventHandler<HTMLElement> | undefinedno
onDurationChangeCaptureReactEventHandler<HTMLElement> | undefinedno
onEmptiedReactEventHandler<HTMLElement> | undefinedno
onEmptiedCaptureReactEventHandler<HTMLElement> | undefinedno
onEncryptedReactEventHandler<HTMLElement> | undefinedno
onEncryptedCaptureReactEventHandler<HTMLElement> | undefinedno
onEndedReactEventHandler<HTMLElement> | undefinedno
onEndedCaptureReactEventHandler<HTMLElement> | undefinedno
onErrorReactEventHandler<HTMLElement> | undefinedno
onErrorCaptureReactEventHandler<HTMLElement> | undefinedno
onFocusFocusEventHandler<HTMLElement> | undefinedno
onFocusCaptureFocusEventHandler<HTMLElement> | undefinedno
onGotPointerCapturePointerEventHandler<HTMLElement> | undefinedno
onGotPointerCaptureCapturePointerEventHandler<HTMLElement> | undefinedno
onInputInputEventHandler<HTMLElement> | undefinedno
onInputCaptureInputEventHandler<HTMLElement> | undefinedno
onInvalidReactEventHandler<HTMLElement> | undefinedno
onInvalidCaptureReactEventHandler<HTMLElement> | undefinedno
onKeyDownKeyboardEventHandler<HTMLElement> | undefinedno
onKeyDownCaptureKeyboardEventHandler<HTMLElement> | undefinedno
onKeyPressKeyboardEventHandler<HTMLElement> | undefinedno
onKeyPressCaptureKeyboardEventHandler<HTMLElement> | undefinedno
onKeyUpKeyboardEventHandler<HTMLElement> | undefinedno
onKeyUpCaptureKeyboardEventHandler<HTMLElement> | undefinedno
onLoadReactEventHandler<HTMLElement> | undefinedno
onLoadCaptureReactEventHandler<HTMLElement> | undefinedno
onLoadedDataReactEventHandler<HTMLElement> | undefinedno
onLoadedDataCaptureReactEventHandler<HTMLElement> | undefinedno
onLoadedMetadataReactEventHandler<HTMLElement> | undefinedno
onLoadedMetadataCaptureReactEventHandler<HTMLElement> | undefinedno
onLoadStartReactEventHandler<HTMLElement> | undefinedno
onLoadStartCaptureReactEventHandler<HTMLElement> | undefinedno
onLostPointerCapturePointerEventHandler<HTMLElement> | undefinedno
onLostPointerCaptureCapturePointerEventHandler<HTMLElement> | undefinedno
onMouseDownMouseEventHandler<HTMLElement> | undefinedno
onMouseDownCaptureMouseEventHandler<HTMLElement> | undefinedno
onMouseEnterMouseEventHandler<HTMLElement> | undefinedno
onMouseLeaveMouseEventHandler<HTMLElement> | undefinedno
onMouseMoveMouseEventHandler<HTMLElement> | undefinedno
onMouseMoveCaptureMouseEventHandler<HTMLElement> | undefinedno
onMouseOutMouseEventHandler<HTMLElement> | undefinedno
onMouseOutCaptureMouseEventHandler<HTMLElement> | undefinedno
onMouseOverMouseEventHandler<HTMLElement> | undefinedno
onMouseOverCaptureMouseEventHandler<HTMLElement> | undefinedno
onMouseUpMouseEventHandler<HTMLElement> | undefinedno
onMouseUpCaptureMouseEventHandler<HTMLElement> | undefinedno
onPasteClipboardEventHandler<HTMLElement> | undefinedno
onPasteCaptureClipboardEventHandler<HTMLElement> | undefinedno
onPauseReactEventHandler<HTMLElement> | undefinedno
onPauseCaptureReactEventHandler<HTMLElement> | undefinedno
onPlayReactEventHandler<HTMLElement> | undefinedno
onPlayCaptureReactEventHandler<HTMLElement> | undefinedno
onPlayingReactEventHandler<HTMLElement> | undefinedno
onPlayingCaptureReactEventHandler<HTMLElement> | undefinedno
onPointerCancelPointerEventHandler<HTMLElement> | undefinedno
onPointerCancelCapturePointerEventHandler<HTMLElement> | undefinedno
onPointerDownPointerEventHandler<HTMLElement> | undefinedno
onPointerDownCapturePointerEventHandler<HTMLElement> | undefinedno
onPointerEnterPointerEventHandler<HTMLElement> | undefinedno
onPointerLeavePointerEventHandler<HTMLElement> | undefinedno
onPointerMovePointerEventHandler<HTMLElement> | undefinedno
onPointerMoveCapturePointerEventHandler<HTMLElement> | undefinedno
onPointerOutPointerEventHandler<HTMLElement> | undefinedno
onPointerOutCapturePointerEventHandler<HTMLElement> | undefinedno
onPointerOverPointerEventHandler<HTMLElement> | undefinedno
onPointerOverCapturePointerEventHandler<HTMLElement> | undefinedno
onPointerUpPointerEventHandler<HTMLElement> | undefinedno
onPointerUpCapturePointerEventHandler<HTMLElement> | undefinedno
onProgressReactEventHandler<HTMLElement> | undefinedno
onProgressCaptureReactEventHandler<HTMLElement> | undefinedno
onRateChangeReactEventHandler<HTMLElement> | undefinedno
onRateChangeCaptureReactEventHandler<HTMLElement> | undefinedno
onResetReactEventHandler<HTMLElement> | undefinedno
onResetCaptureReactEventHandler<HTMLElement> | undefinedno
onScrollUIEventHandler<HTMLElement> | undefinedno
onScrollCaptureUIEventHandler<HTMLElement> | undefinedno
onScrollEndUIEventHandler<HTMLElement> | undefinedno
onScrollEndCaptureUIEventHandler<HTMLElement> | undefinedno
onSeekedReactEventHandler<HTMLElement> | undefinedno
onSeekedCaptureReactEventHandler<HTMLElement> | undefinedno
onSeekingReactEventHandler<HTMLElement> | undefinedno
onSeekingCaptureReactEventHandler<HTMLElement> | undefinedno
onSelectReactEventHandler<HTMLElement> | undefinedno
onSelectCaptureReactEventHandler<HTMLElement> | undefinedno
onStalledReactEventHandler<HTMLElement> | undefinedno
onStalledCaptureReactEventHandler<HTMLElement> | undefinedno
onSubmitSubmitEventHandler<HTMLElement> | undefinedno
onSubmitCaptureSubmitEventHandler<HTMLElement> | undefinedno
onSuspendReactEventHandler<HTMLElement> | undefinedno
onSuspendCaptureReactEventHandler<HTMLElement> | undefinedno
onTimeUpdateReactEventHandler<HTMLElement> | undefinedno
onTimeUpdateCaptureReactEventHandler<HTMLElement> | undefinedno
onToggleToggleEventHandler<HTMLElement> | undefinedno
onTouchCancelTouchEventHandler<HTMLElement> | undefinedno
onTouchCancelCaptureTouchEventHandler<HTMLElement> | undefinedno
onTouchEndTouchEventHandler<HTMLElement> | undefinedno
onTouchEndCaptureTouchEventHandler<HTMLElement> | undefinedno
onTouchMoveTouchEventHandler<HTMLElement> | undefinedno
onTouchMoveCaptureTouchEventHandler<HTMLElement> | undefinedno
onTouchStartTouchEventHandler<HTMLElement> | undefinedno
onTouchStartCaptureTouchEventHandler<HTMLElement> | undefinedno
onTransitionCancelTransitionEventHandler<HTMLElement> | undefinedno
onTransitionCancelCaptureTransitionEventHandler<HTMLElement> | undefinedno
onTransitionEndTransitionEventHandler<HTMLElement> | undefinedno
onTransitionEndCaptureTransitionEventHandler<HTMLElement> | undefinedno
onTransitionRunTransitionEventHandler<HTMLElement> | undefinedno
onTransitionRunCaptureTransitionEventHandler<HTMLElement> | undefinedno
onTransitionStartTransitionEventHandler<HTMLElement> | undefinedno
onTransitionStartCaptureTransitionEventHandler<HTMLElement> | undefinedno
onVolumeChangeReactEventHandler<HTMLElement> | undefinedno
onVolumeChangeCaptureReactEventHandler<HTMLElement> | undefinedno
onWaitingReactEventHandler<HTMLElement> | undefinedno
onWaitingCaptureReactEventHandler<HTMLElement> | undefinedno
onWheelWheelEventHandler<HTMLElement> | undefinedno
onWheelCaptureWheelEventHandler<HTMLElement> | undefinedno
partstring | undefinedno
popover"" | "auto" | "hint" | "manual" | undefinedno
popoverTargetstring | undefinedno
popoverTargetAction"hide" | "show" | "toggle" | undefinedno
prefixstring | undefinedno
propertystring | undefinedno
radioGroupstring | undefinedno
relstring | undefinedno
resourcestring | undefinedno
resultsnumber | undefinedno
revstring | undefinedno
roleAriaRole | undefinedno
securitystring | undefinedno
side"left" | "right" | undefinedno
slotstring | undefinedno
spellCheckBooleanish | undefinedno
suppressContentEditableWarningboolean | undefinedno
suppressHydrationWarningboolean | undefinedno
tabIndexnumber | undefinedno
translate"no" | "yes" | undefinedno
typeofstring | undefinedno
unselectable"off" | "on" | undefinedno
vocabstring | undefinedno

Proof

Contrast

measured on 0.2.0

StateForegroundBackgroundRatioFloor
defaultrgb(7 21 34)rgb(239 239 239)16.03AA 4.5
default (dark)rgb(248 245 240)rgb(107 107 107)4.90AA 4.5

Keyboard

measured on 0.2.0

KeyAction
EnterOpen the dialog or activate its Close button
SpaceOpen the dialog from its trigger
TabMove forward and wrap focus inside the dialog
Shift+TabWrap backward focus inside the dialog
EscapeClose the dialog and restore trigger focus

Size

93161 gzip bytes · measured on 0.2.0

Motion

The drawer enters from the edge of the screen.

Configured duration: 200 ms

Reduced motion: none

Motion timing

Observed duration: 200 ms · measured on 0.2.0

Reduced motion

passed · measured on 0.2.0

Example

import { Drawer } from "@/components/ui/_kit/overlay/drawer/Drawer";
import { useState } from "react";

export default function Example() {
const [open, setOpen] = useState(false);
return <><button onClick={() => setOpen(true)}>Open drawer</button><Drawer open={open} title="Settings" onClose={() => setOpen(false)}><p>Choose your settings.</p></Drawer></>;
}

not on native yet