Drawer
Stores menus or navigation; mainly for mobile/tablet with limited space.
Last updated 11/1/2024
Variants
Supports left and right placement, plus a full-screen mode. Avoid Full on spacious desktop layouts.
- Right
- Navigation 1
- Navigation 2
- Navigation 3
- Left
- Navigation 1
- Navigation 2
- Navigation 3
- Full
- Navigation 1
- Navigation 2
- Navigation 3
import { Drawer, IconButton, ListItem, List } from "@serendie/ui";
import { SerendieSymbol } from "@serendie/symbols";
import { Dd, Dl, Dt } from "src/components/LayoutUtils";
import { useState } from "react";
export function TypeSample() {
const [leftOpen, setLeftOpen] = useState(false);
const [rightOpen, setRightOpen] = useState(false);
const [fullOpen, setFullOpen] = useState(false);
return (
<Dl>
<Dt>Right</Dt>
<Dd>
<IconButton
icon={<SerendieSymbol name="menu" />}
shape="rectangle"
styleType="outlined"
onClick={() => {
setRightOpen(true);
}}
/>
<Drawer isOpen={rightOpen} onOpenChange={(e) => setRightOpen(e.open)}>
<List>
<ListItem title="Navigation 1" />
<ListItem title="Navigation 2" />
<ListItem title="Navigation 3" />
</List>
</Drawer>
</Dd>
<Dt>Left</Dt>
<Dd>
<IconButton
icon={<SerendieSymbol name="menu" />}
shape="rectangle"
styleType="outlined"
onClick={() => {
setLeftOpen(true);
}}
/>
<Drawer
isOpen={leftOpen}
onOpenChange={(e) => setLeftOpen(e.open)}
type="left"
>
<List>
<ListItem title="Navigation 1" />
<ListItem title="Navigation 2" />
<ListItem title="Navigation 3" />
</List>
</Drawer>
</Dd>
<Dt>Full</Dt>
<Dd>
<IconButton
icon={<SerendieSymbol name="menu" />}
shape="rectangle"
styleType="outlined"
onClick={() => {
setFullOpen(true);
}}
/>
<Drawer
isOpen={fullOpen}
onOpenChange={(e) => setFullOpen(e.open)}
type="full"
>
<List>
<ListItem title="Navigation 1" />
<ListItem title="Navigation 2" />
<ListItem title="Navigation 3" />
</List>
</Drawer>
</Dd>
</Dl>
);
}