Docs
抽屉

抽屉

React 的抽屉组件。

关于

¥About

Drawer 由 emilkowalski_Vaul 之上构建。

¥Drawer is built on top of Vaul by emilkowalski_.

安装

¥Installation

pnpm dlx shadcn@latest add drawer

用法

¥Usage

import {
  Drawer,
  DrawerClose,
  DrawerContent,
  DrawerDescription,
  DrawerFooter,
  DrawerHeader,
  DrawerTitle,
  DrawerTrigger,
} from "@/components/ui/drawer"
<Drawer>
  <DrawerTrigger>Open</DrawerTrigger>
  <DrawerContent>
    <DrawerHeader>
      <DrawerTitle>Are you absolutely sure?</DrawerTitle>
      <DrawerDescription>This action cannot be undone.</DrawerDescription>
    </DrawerHeader>
    <DrawerFooter>
      <Button>Submit</Button>
      <DrawerClose>
        <Button variant="outline">Cancel</Button>
      </DrawerClose>
    </DrawerFooter>
  </DrawerContent>
</Drawer>

示例

¥Examples

响应式对话框

¥Responsive Dialog

你可以组合 DialogDrawer 组件来创建响应式对话框。这会在桌面上渲染 Dialog 组件,在移动设备上渲染 Drawer 组件。

¥You can combine the Dialog and Drawer components to create a responsive dialog. This renders a Dialog component on desktop and a Drawer on mobile.