Files
Ivan VasilovandJoshen Lim 9fa96977be chore: Minor prettier fixes (#43849)
This PR fixes some prettier issues:
- Bump and unify all prettier versions to 3.7.3 across teh whole repo
- Bump the SQL prettier plugin
- When running `test:prettier`, check `mdx` files also
- Run the new prettier format on all files

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2026-03-17 11:17:42 +01:00

139 lines
3.3 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: Sheet
description: Extends the Dialog component to display content that complements the main content of the screen.
component: true
links:
doc: https://www.radix-ui.com/docs/primitives/components/dialog
api: https://www.radix-ui.com/docs/primitives/components/dialog#api-reference
source:
radix: true
shadcn: true
---
<ComponentPreview name="sheet-demo" peekCode wide />
1. **Use for side panels**
- Forms with multiple fields
- Settings panels
- Detailed editors
2. **Consider screen size**
- Sheets work well on desktop
- On mobile, consider full-screen or bottom sheet variants
3. **Structure content clearly**
- Use `SheetHeader` and `SheetTitle` for context
- Use `SheetSection` to group related fields
- Use `SheetFooter` for actions
## Installation
<Tabs defaultValue="cli">
<TabsList>
<TabsTrigger value="cli">CLI</TabsTrigger>
<TabsTrigger value="manual">Manual</TabsTrigger>
</TabsList>
<TabsContent value="cli">
```bash
npx shadcn-ui@latest add sheet
```
</TabsContent>
<TabsContent value="manual">
<Steps>
<Step>Install the following dependencies:</Step>
```bash
npm install @radix-ui/react-dialog
```
<Step>Copy and paste the following code into your project.</Step>
<ComponentSource name="sheet" />
<Step>Update the import paths to match your project setup.</Step>
</Steps>
</TabsContent>
</Tabs>
### Usage
```tsx
import {
Sheet,
SheetContent,
SheetDescription,
SheetHeader,
SheetTitle,
SheetTrigger,
} from '@/components/ui/sheet'
```
```tsx
<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>
```
## Examples
### Nonmodal
This sheet is nonmodal, meaning it does not block the underlying content. It’s useful when
you want to display content that complements the main content of the screen.
<ComponentPreview name="sheet-nonmodal" />
To have the underlying content resize to fit the sheet (so nothing is overlapping) use the Sidebar component
or build a custom panel. You can refer to the following Studio components for guidance:
- `AIAssistant`
- `EditorPanel`
- `AdvisorPanel`
See [`LayoutSidebarProvider`](https://github.com/supabase/supabase/blob/master/apps/studio/components/layouts/ProjectLayout/LayoutSidebar/LayoutSidebarProvider.tsx) for more.
### Size
You can adjust the size of the sheet using CSS classes:
```tsx {3}
<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>
```
### Side
Use the `side` property to `<SheetContent />` to indicate the edge of the screen where the component will appear. The values can be `top`, `right`, `bottom` or `left`.
<ComponentPreview name="sheet-side" />
That said, stick to the default `right` unless you have a strong reason not to.