Components组件Radix UIRadix UI 组件
抽屉
从屏幕边缘滑入的补充内容面板。
中文模式已适配导航、标题、简介、目录与常用章节名称。翻译状态:部分完成;技术正文目前仍为英文。
About
Drawer is built on top of Vaul by emilkowalski.
安装
Command
Manual
Use the JGuang UI Registry URL provided on /systems/jguang-ui#install.
安装以下依赖:
npm install vaul
将以下代码复制到你的项目中。
View complete source: components/ui/drawer.tsx
根据项目配置更新导入路径。
用法
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>
Composition
Use the following composition to build a Drawer:
Drawer
├── DrawerTrigger
└── DrawerContent
├── DrawerHeader
│ ├── DrawerTitle
│ └── DrawerDescription
└── DrawerFooter
Scrollable Content
Keep actions visible while the content scrolls.
Loading JGuang UI example…
Sides
Use the direction prop to set the side of the drawer. Available options are top, right, bottom, and left.
Loading JGuang UI example…
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.
Loading JGuang UI example…
从右到左布局
To enable RTL support in JGuang UI, see the RTL configuration guide.
Loading JGuang UI example…
API 参考
See the Vaul documentation for the full API reference.
来源: components/radix/drawer.mdx
JGuang UI 技术文档。