Skip to content

Drawer

A drawer component with smooth slide animations. Supports multiple drawers, ESC key to close, body scroll lock, and optional background overlay.

You can preview the Drawer component in action on the Playground.

<!-- Drawer -->
<div
data-drawer="my-drawer"
data-drawer-overlay="true"
class="hidden"
>
Drawer content
<!-- Close Button -->
<button data-drawer-close="my-drawer">Close</button>
</div>
<!-- Trigger -->
<button data-drawer-trigger="my-drawer">Open Drawer</button>
PropTypeDefaultDescription
idstringUnique identifier for the drawer.
overlaystringtrueWhether to show a background overlay when the drawer is open.
classNamestringAdditional CSS classes for the drawer.

Use the DrawerTrigger component or the data-drawer-trigger attribute on any element to open the drawer.

<button data-drawer-trigger="my-drawer">Open Drawer</button>
PropTypeDescription
idstringThe unique identifier of the drawer to open.
classNamestringAdditional CSS classes for the trigger element.

Use the DrawerClose component or the data-drawer-close attribute on any element to close the drawer.

<button data-drawer-close="my-drawer">Close Drawer</button>
PropTypeDescription
idstringThe unique identifier of the drawer to close.
classNamestringAdditional CSS classes for the close element.

The Drawer component supports the following CSS variables for customization:

--drawer-bg: #ffffff;
--drawer-border: rgba(0, 0, 0, 0.1);
--drawer-width: 400px;
--drawer-padding: 20px;
--drawer-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);