Skip to content

Drawer

The Drawer component displays content in a slide-in panel from the right edge of the screen. It provides a flexible way to create side panels with backdrop, positioning, and focus management.

import { useState } from 'react';
import {
Button,
Drawer,
useDisclosure,
} from '@fintech-sandpit/ui/react';
const {
open,
onOpen,
onClose,
} = useDisclosure();
return (
<>
<Button
colorScheme="primary"
onClick={onOpen}
>
Open
</Button>
<Drawer.Root
open={open}
onOpen={onOpen}
onClose={onClose}
>
<Drawer.Content>
<Drawer.CloseTrigger />
<Drawer.Header>
Drawer Title
</Drawer.Header>
<Drawer.Body>
Drawer Body Text
</Drawer.Body>
<Drawer.Footer>
<Button onClick={onClose}>
Close Drawer
</Button>
</Drawer.Footer>
</Drawer.Content>
</Drawer.Root>
</>
);
NameTypeDefaultDescription
openbooleanfalseWhether the drawer is open (controlled)
defaultOpenbooleanfalseWhether the drawer is open by default (uncontrolled)
modalbooleantrueWhether the drawer is modal.2
closeOnInteractOutsidebooleantrueWhether to close on outside interaction
closeOnEscapebooleantrueWhether to close on Escape key
NameTypeDefaultDescription
placementDrawerPlacementrightThe placement of the drawer
containerRefObject<HTMLElement>The container to render the drawer in
  1. Can be used with the v-model directive for two-way binding.
  2. When true, focus is trapped inside the drawer and interaction with elements outside is blocked. When false, users can interact with other page elements while the drawer is open.
NameArgumentsDescription
onOpen() => voidCallback fired when drawer is opened
onClose() => voidCallback fired when drawer is closed
type DrawerPlacement = 'top' | 'bottom' | 'left' | 'right'