# 抽屉 · JGuang UI

> 从屏幕边缘滑入的补充内容面板。

- 页面: https://jiguang132.com/zh/systems/jguang-ui/docs/components/radix/drawer
- 改编自: shadcn/ui 文档 (MIT) @ bc0705384b51252af26dcc65425b216bf5eb063c
- 说明：正文保留英文原文。

> 示例 `drawer-demo`: 交互预览见 https://jiguang132.com/zh/systems/jguang-ui/docs/components/radix/drawer


## About

Drawer is built on top of [Vaul](https://github.com/emilkowalski/vaul) by [emilkowalski](https://twitter.com/emilkowalski).

## Installation


  

**Command**


  

**Manual**


```text
Use the JGuang UI Registry URL provided on /systems/jguang-ui#install.
```


### Install the following dependencies:


```bash
npm install vaul
```


### Copy and paste the following code into your project.


[View complete source: components/ui/drawer.tsx](/r/jguang-ui/radix/drawer.json)


### Update the import paths to match your project setup.


## Usage

```tsx showLineNumbers
import {
  Drawer,
  DrawerClose,
  DrawerContent,
  DrawerDescription,
  DrawerFooter,
  DrawerHeader,
  DrawerTitle,
  DrawerTrigger,
} from "@/components/ui/drawer"
```

```tsx showLineNumbers
<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>
```

## Composition

Use the following composition to build a `Drawer`:

```text
Drawer
├── DrawerTrigger
└── DrawerContent
    ├── DrawerHeader
    │   ├── DrawerTitle
    │   └── DrawerDescription
    └── DrawerFooter
```

## Scrollable Content

Keep actions visible while the content scrolls.


> 示例 `drawer-scrollable-content`: 交互预览见 https://jiguang132.com/zh/systems/jguang-ui/docs/components/radix/drawer


## Sides

Use the `direction` prop to set the side of the drawer. Available options are `top`, `right`, `bottom`, and `left`.


> 示例 `drawer-sides`: 交互预览见 https://jiguang132.com/zh/systems/jguang-ui/docs/components/radix/drawer


## Responsive Dialog

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.


> 示例 `drawer-dialog`: 交互预览见 https://jiguang132.com/zh/systems/jguang-ui/docs/components/radix/drawer


## RTL

To enable RTL support in JGuang UI, see the [RTL configuration guide](/systems/jguang-ui/docs/rtl).


> 示例 `drawer-rtl`: 交互预览见 https://jiguang132.com/zh/systems/jguang-ui/docs/components/radix/drawer


## API Reference

See the [Vaul documentation](https://vaul.emilkowal.ski/getting-started) for the full API reference.

---

JGuang 全部资源索引: https://jiguang132.com/llms.txt
