Drawer

The Drawer component is a slide-over panel that overlays content, often used for navigation or displaying additional information without navigating away from the current page.

Usage

Basic Usage

function Example() {
const [isOpen, setIsOpen] = React.useState(false);
const toggleDrawer = () => {
setIsOpen(!isOpen);
};
return (
<>
<Button variant="ghost" onClick={toggleDrawer}>
Open
</Button>
<Drawer.Root overlayVariant="translucent" open={isOpen} onClose={toggleDrawer}>
<Drawer.Header title={<Icon type="Zap" />} />
<Drawer.Content>
<Menu.Root
defaultValue=""
items={[
{ value: 'home', label: 'Home', iconPrepend: <Icon type="Home" />, href: '#home' },
{ value: 'about', label: 'About', iconPrepend: <Icon type="HelpCircle" />, href: '#about' },
{ value: 'contact', label: 'Contact', iconPrepend: <Icon type="Package" />, href: '#contact' },
]}
/>
</Drawer.Content>
<Drawer.Footer align="end">
<Flex width="100%" height="100%" justify={'end'} align={'center'}>
<Icon type="Github" />
</Flex>
</Drawer.Footer>
</Drawer.Root>
</>
);
}

API

Props

Drawer

PropTypeDefaultRequired
classNamestring--
styleCSSProperties--
childrenReactNode--
openboolean--
widthCSSProperties--
placement'left' | 'right'--
variant'default' | 'confirm'--
outlinedboolean--
overlatVariant'transparent' | 'translucent--
onClose() => void--
MarginPropsToken<MarginProps>--
colorThemeAccentColor--
sizeResponsive<Size>'medium'-

Header

PropTypeDefaultRequired
classNamestring--
styleCSSProperties--
titleReactNode--
actionReactNode--

Content

PropTypeDefaultRequired
classNamestring--
styleCSSProperties--
childrenReactNode--

Footer

PropTypeDefaultRequired
classNamestring--
styleCSSProperties--
childrenReactNode--
Callout
Previous
Modal
Next