XiodUI
HomeDocs
OverviewComponentsStyling & CustomizationChangelog

Components

  • Accordion
  • Agent Steps
  • Alert
  • Alert Dialog
  • Aspect Ratio
  • Autocomplete
  • Avatar
  • Badge
  • Breadcrumb
  • Button
  • Button Group
  • Button Split
  • Calendar
  • Card
  • Carousel
  • Checkbox
  • Circular Progress
  • Collapsible
  • Color Picker
  • Combobox
  • Command
  • Context Menu
  • Copy To Clipboard
  • Corner Badge
  • Dashboard Grid
  • Date Picker
  • Dialog
  • Dot Matrix
  • Draggable
    Updated
  • Drawer
  • Empty
  • Field
  • Fieldset
  • File Upload
    Updated
  • Form
  • Frame
  • Gauge
  • Grid
  • Group
  • Input
  • Input Group
  • Input OTP
  • Input Payment
  • Input Phone
    Updated
  • Input Sensitive
  • Kbd
  • Kinetic Click
  • Label
  • List Box
    Updated
  • Loader
  • Marker
  • Menu
  • Menubar
  • Message
  • Meter
  • Morphic Toast
  • Navigation Menu
  • Number Field
  • Option Picker
  • Orb
  • Pagination
  • Popover
  • Preview Card
    Updated
  • Progress
  • Radio
  • Resizable
  • Ruler Picker
  • Scroll Area
  • Scroll Bar
  • Select
  • Separator
  • Sidebar
  • Skeleton
  • Slider
  • Sortable
  • Switch
  • Table
  • Tabs
  • Text
  • Textarea
  • Timeline
  • Toast
  • Toggle
  • Toggle Group
  • Toolbar
  • Tooltip
  • Waveform
  • Wheel Picker

Loading...

Preview Skeleton

Installation Skeleton

Usage Skeleton

API Reference Skeleton

Sponsors

Support the development of XiodUI and help us build the best component library on Earth.

+++
Sponsor on GitHub

Drawer

Previous: DraggableNext: Empty

A panel that slides in from an edge of the screen.

Preview

Loading Preview...

Installation

bun add xiod-ui

Usage

Imports

1import {2  Drawer,3  DrawerTrigger,4  DrawerClose,5  DrawerSwipeArea,6  DrawerBackdrop,7  DrawerViewport,8  DrawerPopup,9  DrawerHeader,10  DrawerFooter,11  DrawerTitle,12  DrawerDescription,13  DrawerPanel,14  DrawerBar,15  DrawerMenu,16  DrawerMenuItem,17  DrawerMenuSeparator,18  DrawerMenuGroup,19  DrawerMenuGroupLabel,20  DrawerMenuTrigger,21  DrawerMenuCheckboxItem,22  DrawerMenuRadioGroup,23  DrawerMenuRadioItem,24  DrawerPortal,25  DrawerContent,26  DrawerCreateHandle27} from "xiod-ui/drawer";

Anatomy

1<Drawer>2  <DrawerTrigger />3  <DrawerPopup>4    <DrawerHeader>5      <DrawerTitle />6      <DrawerDescription />7    </DrawerHeader>8    <DrawerFooter>9      <DrawerClose />10    </DrawerFooter>11  </DrawerPopup>12</Drawer>

API Reference

Detailed documentation of properties and options.

Drawer

PropTypeDefaultDescription
actionsRef
RefObject<DrawerRootActions | null>
–

A ref to imperative actions.

  • unmount: Ends the closing phase of the drawer after an externally controlled closing animation finishes.

Call preventUnmountOnClose() in onOpenChange first, otherwise the drawer completes closing on its own. Whether it leaves the DOM is decided by keepMounted on the portal.

  • close: Closes the drawer imperatively when called.
DraggableEmpty
children
ReactNode | PayloadChildRenderFunction<unknown>
–

The content of the drawer.

defaultOpen
boolean
false

Whether the drawer is initially open.

To render a controlled drawer, use the open prop instead.

defaultSnapPoint
DrawerSnapPoint|null
–

The initial snap point value when uncontrolled.

defaultTriggerId
string|null
–

ID of the trigger that the drawer is associated with. This is useful in conjunction with the defaultOpen prop to create an initially open drawer.

disablePointerDismissal
boolean
false

Whether to prevent the drawer from closing on outside presses. For non-modal drawers, this also prevents the drawer from closing when focus moves outside of it.

handle
DrawerHandle<unknown>
–

A handle to associate the drawer with a trigger. If specified, allows detached triggers to control the drawer's open state. Can be created with the Drawer.createHandle() method.

modal
boolean|"trap-focus"
true

Determines if the drawer enters a modal state when open.

  • true: user interaction is limited to just the drawer: focus is trapped, document page scroll is locked, and pointer interactions on outside elements are disabled.
  • false: user interaction with the rest of the document is allowed.
  • 'trap-focus': focus is trapped inside the drawer, but document page scroll is not locked and pointer interactions outside of it remain enabled.
onOpenChange
((open: boolean, eventDetails: DrawerRootChangeEventDetails) => void)
–

Event handler called when the drawer is opened or closed.

onOpenChangeComplete
((open: boolean) => void)
–

Event handler called after any animations complete when the drawer is opened or closed.

onSnapPointChange
((snapPoint: DrawerSnapPoint | null, eventDetails: DrawerRootSnapPointChangeEventDetails) => void)
–

Callback fired when the snap point changes.

open
boolean
–

Whether the drawer is currently open.

position
"top"|"bottom"|"left"|"right"
bottom

The edge of the screen the drawer slides in from. Its parts follow it unless they set their own position. Swipe direction follows it too, unless swipeDirection is set.

snapPoint
DrawerSnapPoint|null
–

The currently active snap point. Use with onSnapPointChange to control the snap point.

snapPoints
DrawerSnapPoint[]
–

Snap points used to position the drawer. Use numbers between 0 and 1 to represent fractions of the viewport height, numbers greater than 1 as pixel values, or strings in px/rem units (for example, '148px' or '30rem').

snapToSequentialPoints
boolean
false

Disables velocity-based snap skipping so drag distance determines the next snap point.

swipeDirection
"left"|"right"|"up"|"down"
'down'

The swipe direction used to dismiss the drawer.

triggerId
string|null
–

ID of the trigger that the drawer is associated with. This is useful in conjunction with the open prop to create a controlled drawer. There's no need to specify this prop when the drawer is uncontrolled (that is, when the open prop is not set).

DrawerTrigger

Accepts className, style and render, plus every native attribute of the element it renders.

PropTypeDefaultDescription
handle
DrawerHandle<unknown>
–

A handle to associate the trigger with a drawer. Can be created with the Drawer.createHandle() method.

id
string
–

ID of the trigger. In addition to being forwarded to the rendered element, it is also used to specify the active trigger for drawers in controlled mode (with the Drawer.Root triggerId prop).

nativeButton
boolean
true

Whether the component renders a native <button> element when replacing it via the render prop. Set to false if the rendered element is not a button (for example, <div>).

payload
unknown
–

A payload to pass to the drawer when it is opened.

DrawerClose

Accepts className, style and render, plus every native attribute of the element it renders.

PropTypeDefaultDescription
nativeButton
boolean
true

Whether the component renders a native <button> element when replacing it via the render prop. Set to false if the rendered element is not a button (for example, <div>).

DrawerSwipeArea

Accepts className, style and render, plus every native attribute of the element it renders.

PropTypeDefaultDescription
disabled
boolean
false

Whether the swipe area is disabled.

position
"top"|"bottom"|"left"|"right"
–

The edge the swipe area sits along. Defaults to the Drawer's position.

swipeDirection
"left"|"right"|"up"|"down"
–

The swipe direction that opens the drawer. Defaults to the opposite of Drawer.Root swipeDirection.

DrawerBackdrop

Accepts className, style and render, plus every native attribute of the element it renders.

PropTypeDefaultDescription
forceRender
boolean
false

Whether the backdrop is forced to render even when nested.

DrawerViewport

Accepts className, style and render, plus every native attribute of the element it renders.

PropTypeDefaultDescription
position
"top"|"bottom"|"left"|"right"
–

The edge of the screen the popup is laid out against. DrawerPopup renders its own viewport, so set this only when composing the parts yourself.

variant
"default"|"straight"|"inset"
default

The popup's shape: default rounds the corners on the inner edge, straight keeps them square, and inset floats the popup away from the screen edges with every corner rounded, from the sm breakpoint up.

DrawerPopup

Accepts className, style and render, plus every native attribute of the element it renders.

PropTypeDefaultDescription
backdrop
boolean
true

Whether to dim the page behind the drawer.

backdropClassName
string
–

Extra classes for the backdrop.

closeIcon
ReactNode
–

Replaces this icon. Accepts any node; null renders no icon. Takes precedence over IconProvider.

finalFocus
boolean | RefObject<HTMLElement | null> | ((closeType: InteractionType) => boolean | void | HTMLElement | null)
–

Determines the element to focus when the drawer is closed.

  • false: Do not move focus.
  • true: Move focus based on the default behavior (trigger or previously focused element).
  • RefObject: Move focus to the ref element.
  • function: Called with the interaction type (mouse, touch, pen, or keyboard). Return an element to focus, true to use the default behavior, or false/undefined to do nothing.
initialFocus
boolean | RefObject<HTMLElement | null> | ((openType: InteractionType) => boolean | void | HTMLElement | null)
–

Determines the element to focus when the drawer is opened.

  • false: Do not move focus.
  • true: Move focus based on the default behavior (first tabbable element or popup).
  • RefObject: Move focus to the ref element.
  • function: Called with the interaction type (mouse, touch, pen, or keyboard). Return an element to focus, true to use the default behavior, or false/undefined to do nothing.
labels
Partial<CloseLabels>
–

Replaces the built-in text of this drawer. Takes precedence over LabelsProvider.

position
"top"|"bottom"|"left"|"right"
–

The edge the popup slides in from. Defaults to the Drawer's position.

showBar
boolean
false

Whether to show the grab bar along the popup's inner edge.

showCloseButton
boolean
false

Whether to show a close button in the top corner.

variant
"default"|"straight"|"inset"
default

The popup's shape: default rounds the corners on the inner edge, straight keeps them square, and inset floats the popup away from the screen edges with every corner rounded, from the sm breakpoint up.

DrawerHeader

Accepts render, plus every native <div> attribute.

PropTypeDefaultDescription
allowSelection
boolean
false

Whether text in the header can be selected with a mouse. When false, dragging on it with a mouse swipes the drawer instead.

DrawerFooter

Accepts render, plus every native <div> attribute.

PropTypeDefaultDescription
allowSelection
boolean
true

Whether text in the footer can be selected with a mouse. When false, dragging on it with a mouse swipes the drawer instead.

variant
"default"|"bare"
default

The popup's shape: default rounds the corners on the inner edge, straight keeps them square, and inset floats the popup away from the screen edges with every corner rounded, from the sm breakpoint up.

DrawerTitle

Accepts className, style and render, plus every native attribute of the element it renders.

DrawerDescription

Accepts className, style and render, plus every native attribute of the element it renders.

DrawerPanel

Accepts render, plus every native <div> attribute.

PropTypeDefaultDescription
allowSelection
boolean
true

Whether text in the panel can be selected with a mouse. When false, dragging on it with a mouse swipes the drawer instead.

scrollable
boolean
true

Whether the panel scrolls its content when it doesn't fit.

scrollFade
boolean
true

Whether the content fades out at an edge that has more to scroll to.

DrawerBar

Accepts render, plus every native <div> attribute.

PropTypeDefaultDescription
position
"top"|"bottom"|"left"|"right"
–

The edge the drawer slides in from, which decides where the bar sits and which way it points. Defaults to the Drawer's position.

DrawerMenu

Accepts render, plus every native <nav> attribute.

DrawerMenuItem

Accepts render, plus every native <button> attribute.

PropTypeDefaultDescription
variant
"default"|"destructive"
default

The popup's shape: default rounds the corners on the inner edge, straight keeps them square, and inset floats the popup away from the screen edges with every corner rounded, from the sm breakpoint up.

DrawerMenuSeparator

Accepts render, plus every native <div> attribute.

DrawerMenuGroup

Accepts render, plus every native <div> attribute.

DrawerMenuGroupLabel

Accepts render, plus every native <div> attribute.

DrawerMenuTrigger

Accepts className, style and render, plus every native attribute of the element it renders.

PropTypeDefaultDescription
handle
DrawerHandle<unknown>
–

A handle to associate the trigger with a drawer. Can be created with the Drawer.createHandle() method.

icon
ReactNode
–

Replaces this icon. Accepts any node; null renders no icon. Takes precedence over IconProvider.

id
string
–

ID of the trigger. In addition to being forwarded to the rendered element, it is also used to specify the active trigger for drawers in controlled mode (with the Drawer.Root triggerId prop).

nativeButton
boolean
true

Whether the component renders a native <button> element when replacing it via the render prop. Set to false if the rendered element is not a button (for example, <div>).

payload
unknown
–

A payload to pass to the drawer when it is opened.

DrawerMenuCheckboxItem

Accepts className, style and render, plus every native attribute of the element it renders.

PropTypeDefaultDescription
checked
boolean
undefined

Whether the checkbox is currently ticked.

To render an uncontrolled checkbox, use the defaultChecked prop instead.

defaultChecked
boolean
false

Whether the checkbox is initially ticked.

To render a controlled checkbox, use the checked prop instead.

disabled
boolean
false

Whether the component should ignore user interaction.

form
string
–

Identifies the form that owns the hidden input. Useful when the checkbox is rendered outside the form.

icon
ReactNode
–

Replaces the check icon. Accepts any node; null renders no icon. Takes precedence over IconProvider.

id
string
–

The id of the input element.

indeterminate
boolean
false

Whether the checkbox is in a mixed state: neither ticked, nor unticked.

inputRef
Ref<HTMLInputElement>
–

A ref to access the hidden <input> element.

name
string
undefined

Identifies the field when a form is submitted.

nativeButton
boolean
false

Whether the component renders a native <button> element when replacing it via the render prop. Set to true if the rendered element is a native button.

onCheckedChange
((checked: boolean, eventDetails: CheckboxRootChangeEventDetails) => void)
–

Event handler called when the checkbox is ticked or unticked.

parent
boolean
false

Whether the checkbox controls a group of child checkboxes.

Must be used in a [Checkbox Group](https://base-ui.com/react/components/checkbox-group).

readOnly
boolean
false

Whether the user should be unable to tick or untick the checkbox.

required
boolean
false

Whether the user must tick the checkbox before submitting a form.

uncheckedValue
string
–

The value submitted with the form when the checkbox is unchecked. By default, unchecked checkboxes do not submit any value, matching native checkbox behavior.

value
string
–

The checkbox's value. Identifies it within a [Checkbox Group](https://base-ui.com/react/components/checkbox-group), falling back to name when omitted. When submitting a form, a checked box submits value; with no value, it submits the native "on".

variant
"switch"|"default"
default

The popup's shape: default rounds the corners on the inner edge, straight keeps them square, and inset floats the popup away from the screen edges with every corner rounded, from the sm breakpoint up.

DrawerMenuRadioGroup

Accepts className, style and render, plus every native attribute of the element it renders.

PropTypeDefaultDescription
defaultValue
any
–

The uncontrolled value of the radio button that should be initially selected.

To render a controlled radio group, use the value prop instead.

disabled
boolean
false

Whether the component should ignore user interaction.

form
string
–

Identifies the form that owns the radio inputs. Useful when the radio group is rendered outside the form.

inputRef
Ref<HTMLInputElement>
–

A ref to access the hidden input element.

name
string
–

Identifies the field when a form is submitted.

onValueChange
((value: Value, eventDetails: RadioGroup.ChangeEventDetails) => void)
–

Callback fired when the value changes.

readOnly
boolean
false

Whether the user should be unable to select a different radio button in the group.

required
boolean
false

Whether the user must choose a value before submitting a form.

value
any
–

The controlled value of the radio item that should be currently selected.

To render an uncontrolled radio group, use the defaultValue prop instead.

DrawerMenuRadioItem

Accepts className, style and render, plus every native attribute of the element it renders.

PropTypeDefaultDescription
valueReq
any
–

The unique identifying value of the radio in a group.

disabled
boolean
–

Whether the component should ignore user interaction.

inputRef
Ref<HTMLInputElement>
–

A ref to access the hidden input element.

nativeButton
boolean
false

Whether the component renders a native <button> element when replacing it via the render prop. Set to true if the rendered element is a native button.

readOnly
boolean
–

Whether the user should be unable to select the radio button.

required
boolean
–

Whether the user must choose a value before submitting a form.

DrawerPortal

Accepts className, style and render, plus every native attribute of the element it renders.

PropTypeDefaultDescription
container
HTMLElement | ShadowRoot | RefObject<HTMLElement | ShadowRoot | null> | null
–

A parent element to render the portal element into.

keepMounted
boolean
false

Whether to keep the portal mounted in the DOM while the popup is hidden.

DrawerContent

Accepts className, style and render, plus every native attribute of the element it renders.

Helpers

DrawerCreateHandle is called, not rendered. It creates a handle: pass it as handle to a trigger and to the root, and the trigger can sit anywhere in the tree, outside the root.