Drawer

A drawer component for Svelte, built on Vaul Svelte.

Loading preview…

Installation

Usage

Use drawer for bottom (or edge) panels on mobile and secondary flows. Compose with trigger, content, header, and footer. Set direction on Drawer.Root to top, right, bottom, or left.

1<script lang="ts">
2	import * as Drawer from '~/components/drawer';
3	import { Button, buttonVariants } from '~/components/button';
4</script>
5
6<Drawer.Root>
7	<Drawer.Trigger class={buttonVariants({ variant: 'outline' })}>Open</Drawer.Trigger>
8	<Drawer.Content>
9		<Drawer.Header>
10			<Drawer.Title>Are you absolutely sure?</Drawer.Title>
11			<Drawer.Description>This action cannot be undone.</Drawer.Description>
12		</Drawer.Header>
13		<Drawer.Footer>
14			<Button>Submit</Button>
15			<Drawer.Close class={buttonVariants({ variant: 'outline' })}>Cancel</Drawer.Close>
16		</Drawer.Footer>
17	</Drawer.Content>
18</Drawer.Root>