Sheet
Extends the Dialog component to display content that complements the main content of the screen.
<script lang="ts">
import { Button } from "$lib/components/ui/button/index.js";
import * as Sheet from "$lib/components/ui/sheet/index.js";
import { buttonVariants } from "$lib/components/ui/button/index.js";
import { Input } from "$lib/components/ui/input/index.js";
import { Label } from "$lib/components/ui/label/index.js";
</script>
<Sheet.Root>
<Sheet.Trigger class={buttonVariants({ variant: "outline" })}
>Open</Sheet.Trigger
>
<Sheet.Content side="right">
<Sheet.Header>
<Sheet.Title>Edit profile</Sheet.Title>
<Sheet.Description>
Make changes to your profile here. Click save when you're done.
</Sheet.Description>
</Sheet.Header>
<div class="grid flex-1 auto-rows-min gap-6 px-4">
<div class="grid gap-3">
<Label for="name" class="text-end">Name</Label>
<Input id="name" value="Pedro Duarte" />
</div>
<div class="grid gap-3">
<Label for="username" class="text-end">Username</Label>
<Input id="username" value="@peduarte" />
</div>
</div>
<Sheet.Footer>
<Button type="submit">Save changes</Button>
<Sheet.Close class={buttonVariants({ variant: "outline" })}
>Close</Sheet.Close
>
</Sheet.Footer>
</Sheet.Content>
</Sheet.Root> Installation
pnpm dlx jsrepo@latest add sheetnpx jsrepo@latest add sheetyarn dlx jsrepo@latest add sheetbunx jsrepo@latest add sheetInstall bits-ui:
pnpm add bits-ui -Dnpm install bits-ui -Dyarn add bits-ui -Dbun add bits-ui -DCopy and paste the following code into your project.
import Root from './sheet.svelte';
import Portal from './sheet-portal.svelte';
import Trigger from './sheet-trigger.svelte';
import Close from './sheet-close.svelte';
import Overlay from './sheet-overlay.svelte';
import Content from './sheet-content.svelte';
import Header from './sheet-header.svelte';
import Footer from './sheet-footer.svelte';
import Title from './sheet-title.svelte';
import Description from './sheet-description.svelte';
export {
Root,
Close,
Trigger,
Portal,
Overlay,
Content,
Header,
Footer,
Title,
Description,
//
Root as Sheet,
Close as SheetClose,
Trigger as SheetTrigger,
Portal as SheetPortal,
Overlay as SheetOverlay,
Content as SheetContent,
Header as SheetHeader,
Footer as SheetFooter,
Title as SheetTitle,
Description as SheetDescription
};
Usage
<script lang="ts">
import * as Sheet from '$lib/components/ui/sheet/index.js';
</script> <Sheet.Root>
<Sheet.Trigger>Open</Sheet.Trigger>
<Sheet.Content>
<Sheet.Header>
<Sheet.Title>Are you sure absolutely sure?</Sheet.Title>
<Sheet.Description>
This action cannot be undone. This will permanently delete your account and remove your data
from our servers.
</Sheet.Description>
</Sheet.Header>
</Sheet.Content>
</Sheet.Root> Examples
Side
Pass the side property to <Sheet.Content /> to indicate the edge of the screen where the component will appear. The values can be top, right, bottom or left.
Size
You can adjust the size of the sheet using CSS classes:
<Sheet.Root>
<Sheet.Trigger>Open</Sheet.Trigger>
<Sheet.Content class="w-[400px] sm:w-[540px]">
<Sheet.Header>
<Sheet.Title>Are you absolutely sure?</Sheet.Title>
<Sheet.Description>
This action cannot be undone. This will permanently delete your account and remove your data
from our servers.
</Sheet.Description>
</Sheet.Header>
</Sheet.Content>
</Sheet.Root>