ValyroUI Русская версия

Drawer

Slide-out panels. Free, MIT · Overlays and notifications › Dialogs and panels

Installation

npx valyro-cli@latest add drawer
npx shadcn@latest add https://valyro.xyz/r/drawer.json
npm install valyro-ui

import 'valyro-ui/styles.css';
import { Drawer } from 'valyro-ui';

Props

PropTypeDefault
openbooleanControlled open; use with onOpenChange.
defaultOpenbooleanfalseInitial open when uncontrolled.
onOpenChange(open: boolean) => voidCalled with the new open when it changes.
placement'right' | 'left' | 'start' | 'end' | 'bottom''right'bottom is a sheet with a grab handle that can be dragged down to dismiss. start / end mirror under dir="rtl" (a navigation drawer), left / right stay on that edge.
size'sm' | 'md' | 'lg' | 'full''md'Width for side drawers, maximum height for bottom sheets.
titleReactNodeHeading; becomes the drawer's accessible name.
descriptionReactNodeSupporting text under the title; becomes the drawer's accessible description.
footerReactNodeSticky action bar under the scrollable body.
showClosebooleantrueShow the × button (default true).
closeLabelstring'Close'Accessible name of the × button.
childrenReactNodeBody content; it scrolls between the header and the footer when it overflows. In the compound form, a Drawer.Trigger and a Drawer.Content (with Drawer.Header, .Title, .Description, .Body, .Footer, .Close).
closeOnOverlayClickboolean
closeOnEscapeboolean
initialFocusRefRefObject<HTMLElement | null>
returnFocusRefRefObject<HTMLElement | null>Where focus goes on close when the element that opened the modal is no longer on the page (a deleted row's menu). Without it, focus moves to the first Tab stop near where that element was.
layerClassNamestringClass for the full-screen layer (positioning wrapper).
animation'default' | 'spring'spring: the panel springs in (centred panels drop in from from with a slight tilt, edge panels slide in critically damped). default: the theme's own enter and exit.

Compound parts

Drawer.Trigger (DrawerTrigger), Drawer.Content (DrawerContent), Drawer.Header (DrawerHeader), Drawer.Title (DrawerTitle), Drawer.Description (DrawerDescription), Drawer.Body (DrawerBody), Drawer.Footer (DrawerFooter), Drawer.Close (DrawerClose)

Related components

Previous: Confirm Dialog · Next: Bottom Sheet · All Overlays and notifications