Sheet
Slide-over panel that slides in from the edge of the screen.
Cài đặt
bash
npx @galaxy-stack/nebula-cli add sheetbash
npx @galaxy-stack/nebula-cli add sheetbash
npx @galaxy-stack/nebula-cli add sheetUsage
tsx
import {
Sheet,
SheetContent,
SheetDescription,
SheetHeader,
SheetTitle,
SheetTrigger,
} from '@/components/sheet'
export default function SheetDemo() {
return (
<Sheet>
<SheetTrigger asChild>
<Button variant="outline">Open</Button>
</SheetTrigger>
<SheetContent>
<SheetHeader>
<SheetTitle>Edit profile</SheetTitle>
<SheetDescription>
Make changes to your profile here. Click save when you're done.
</SheetDescription>
</SheetHeader>
<div className="grid gap-4 py-4">
<div className="grid grid-cols-4 items-center gap-4">
<Label htmlFor="name" className="text-right">
Name
</Label>
<Input id="name" value="Pedro Duarte" className="col-span-3" />
</div>
</div>
</SheetContent>
</Sheet>
)
}vue
<script setup lang="ts">
import { ref } from 'vue'
import { Sheet } from '@/components/sheet'
import { Button } from '@/components/button'
const open = ref(false)
</script>
<template>
<Sheet v-model:open="open">
<Button variant="outline" @click="open = true">Open</Button>
<template #content>
<div class="p-6">
<h2 class="text-lg font-semibold">Edit profile</h2>
<p class="text-sm text-muted-foreground">
Make changes to your profile here.
</p>
</div>
</template>
</Sheet>
</template>API Reference
Props
Component này chấp nhận các props sau:
| Prop | Kiểu | Mặc định | Mô tả |
|---|---|---|---|
| ... | ... | ... | ... |
Props
| Prop | Type | Default | Description |
|---|---|---|---|
side | 'top' | 'right' | 'bottom' | 'left' | 'right' | Side from which the sheet slides in |
open | boolean | false | Controls the open state |
onOpenChange | (open: boolean) => void | - | Callback when open state changes |
Examples
Different Sides
tsx
<Sheet>
<SheetContent side="top">Content from top</SheetContent>
</Sheet>
<Sheet>
<SheetContent side="left">Content from left</SheetContent>
</Sheet>Accessibility
- Focus trap when open
- Escape key closes the sheet
- Backdrop click closes the sheet
- Proper ARIA labels
Tác giả
Bùi Trọng Hiếu (kevinbui)
- GitHub: @buikevin
- Email: kevinbui210191@gmail.com
Giấy phép
MIT © 2025 Bùi Trọng Hiếu (kevinbui)
