Skip to content

Drawer

import { Drawer } from 'yarcl';
<Drawer side="left" trigger={<Button>Menu</Button>} title="Navigation">
<Stack as="nav"></Stack>
</Drawer>
<Drawer trigger={<Button>Filters</Button>} title="Filters" footer={<Button>Apply</Button>}>
</Drawer>

Same behavior as Dialog. The drawer fills the screen height; its body scrolls while the header and footer stay in place.

size sets the width, from the same modalSizes as dialogs. Drawers are usually narrower than dialogs, so the library defaults set a component default:

components: { Drawer: { size: 'sm' } }
<Drawer size="lg" title="Order details"></Drawer>
PropTypeDefaultDescription
title requiredReactNodeHeading of the dialog. Also its accessible name.
childrenReactNodeBody content. Scrolls when it doesn't fit.
closeOnBackdropbooleantrueCloses when the backdrop is clicked.
defaultOpenbooleanfalseInitial open state when uncontrolled.
descriptionReactNodeSupporting text below the title. Also its accessible description.
footerReactNodeActions shown at the bottom, e.g. Cancel and Confirm buttons.
onOpenChange(open: boolean) => voidCalled when the dialog opens or closes, including by Esc, the close button or a backdrop click.
openbooleanControlled open state.
side'right' | 'left''right'Edge the drawer is attached to.
sizeModalSizeconfigconfig.defaults.modalSize (Drawer: its component default, `sm` in the library defaults)Width, from the modalSizes config. Height follows the content, up to the viewport.
triggerReactElement<{ onClick?: (event: MouseEvent) => void }, string | JSXElementConstructor<any>>An element that opens the dialog when clicked, e.g. a Button. Optional when controlled.