文档
Sheet
Sheet
扩展 Dialog 组件以显示补充屏幕主要内容的内容。
安装
pnpm dlx shadcn@latest add sheet
用法
import {
Sheet,
SheetContent,
SheetDescription,
SheetHeader,
SheetTitle,
SheetTrigger,
} from "@/components/ui/sheet"
<Sheet>
<SheetTrigger>Open</SheetTrigger>
<SheetContent>
<SheetHeader>
<SheetTitle>Are you absolutely sure?</SheetTitle>
<SheetDescription>
This action cannot be undone. This will permanently delete your account
and remove your data from our servers.
</SheetDescription>
</SheetHeader>
</SheetContent>
</Sheet>
示例
侧边
使用 side
属性来 <SheetContent />
来指示组件将出现屏幕的边缘。 这些值可以是 top
、right
、bottom
或 left
。
尺寸
你可以使用 CSS 类调整 sheet 的尺寸
<Sheet>
<SheetTrigger>Open</SheetTrigger>
<SheetContent className="w-[400px] sm:w-[540px]">
<SheetHeader>
<SheetTitle>Are you absolutely sure?</SheetTitle>
<SheetDescription>
This action cannot be undone. This will permanently delete your account
and remove your data from our servers.
</SheetDescription>
</SheetHeader>
</SheetContent>
</Sheet>