Drawer
화면 가장자리에서 슬라이드되어 나타나는 패널
Basic Usage
기본 Drawer는 화면 하단에서 올라옵니다.
tsx
<Drawer>
<DrawerTrigger asChild>
<Button variant="outline">Open Drawer</Button>
</DrawerTrigger>
<DrawerContent>
<DrawerHeader>
<DrawerTitle>Edit Profile</DrawerTitle>
<DrawerDescription>
Make changes to your profile here. Click save when you're done.
</DrawerDescription>
</DrawerHeader>
<div className="p-4">
<p className="text-sm text-muted-foreground">
Drawer content goes here.
</p>
</div>
<DrawerFooter>
<Button>Save changes</Button>
<DrawerClose asChild>
<Button variant="outline">Cancel</Button>
</DrawerClose>
</DrawerFooter>
</DrawerContent>
</Drawer>Direction: Top
direction prop으로 위에서 내려오는 Drawer를 만들 수 있습니다.
tsx
<Drawer direction="top">
<DrawerTrigger asChild>
<Button variant="outline">Open from Top</Button>
</DrawerTrigger>
<DrawerContent>
<DrawerHeader>
<DrawerTitle>Top Drawer</DrawerTitle>
<DrawerDescription>
This drawer slides down from the top of the screen.
</DrawerDescription>
</DrawerHeader>
<DrawerFooter>
<DrawerClose asChild>
<Button variant="outline">Close</Button>
</DrawerClose>
</DrawerFooter>
</DrawerContent>
</Drawer>Direction: Left / Right
좌우에서 나타나는 Drawer도 지원합니다.
tsx
<Drawer direction="left">
<DrawerTrigger asChild>
<Button variant="outline">Open from Left</Button>
</DrawerTrigger>
<DrawerContent>
<DrawerHeader>
<DrawerTitle>Left Drawer</DrawerTitle>
<DrawerDescription>
This drawer slides in from the left.
</DrawerDescription>
</DrawerHeader>
<DrawerFooter>
<DrawerClose asChild>
<Button variant="outline">Close</Button>
</DrawerClose>
</DrawerFooter>
</DrawerContent>
</Drawer>
<Drawer direction="right">
<DrawerTrigger asChild>
<Button variant="outline">Open from Right</Button>
</DrawerTrigger>
<DrawerContent>
<DrawerHeader>
<DrawerTitle>Right Drawer</DrawerTitle>
</DrawerHeader>
<DrawerFooter>
<DrawerClose asChild>
<Button variant="outline">Close</Button>
</DrawerClose>
</DrawerFooter>
</DrawerContent>
</Drawer>Usage
tsx
import {
Drawer,
DrawerTrigger,
DrawerContent,
DrawerHeader,
DrawerFooter,
DrawerTitle,
DrawerDescription,
DrawerClose,
} from '@gpters-internal/ui';
function Example() {
return (
<Drawer>
<DrawerTrigger asChild>
<Button>Open</Button>
</DrawerTrigger>
<DrawerContent>
<DrawerHeader>
<DrawerTitle>Title</DrawerTitle>
<DrawerDescription>Description</DrawerDescription>
</DrawerHeader>
<DrawerFooter>
<Button>Action</Button>
<DrawerClose asChild>
<Button variant="outline">Cancel</Button>
</DrawerClose>
</DrawerFooter>
</DrawerContent>
</Drawer>
);
}