Sheet
A panel that slides in from the edge of the screen, for filters, navigation or details. Same markup and props in every style: switch the style in the header to see it change.
Basic
Filters from the right, with the actions pinned to the bottom.
<button type="button" class="vin-btn vin-btn--outline" commandfor="sheet-filters" command="show-modal">Filters</button>
<dialog class="vin-dialog vin-sheet" id="sheet-filters" aria-labelledby="sheet-filters-title" aria-describedby="sheet-filters-desc" closedby="any">
<div class="vin-dialog__header">
<h2 class="vin-dialog__title" id="sheet-filters-title">Filters</h2>
<p class="vin-dialog__description" id="sheet-filters-desc">Narrow the list of components.</p>
</div>
<form method="dialog">
<div class="vin-dialog__body">
<div class="vin-field">
<label class="vin-label" for="sheet-q">Search</label>
<input id="sheet-q" class="vin-input" type="search" placeholder="Button, card…">
</div>
<div class="vin-choice">
<input id="sheet-forms" class="vin-checkbox" type="checkbox" checked>
<div class="vin-choice__body">
<label class="vin-choice__label" for="sheet-forms">Forms</label>
</div>
</div>
<div class="vin-choice">
<input id="sheet-overlays" class="vin-checkbox" type="checkbox">
<div class="vin-choice__body">
<label class="vin-choice__label" for="sheet-overlays">Overlays</label>
</div>
</div>
</div>
<div class="vin-dialog__footer">
<button type="button" class="vin-btn vin-btn--outline" commandfor="sheet-filters" command="close">Cancel</button>
<button type="submit" class="vin-btn" value="apply">Show results</button>
</div>
</form>
<button type="button" class="vin-btn vin-btn--ghost vin-btn--icon vin-dialog__close" commandfor="sheet-filters" command="close" aria-label="Close"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg></button>
</dialog>import { Sheet, SheetClose } from "@/components/vin/sheet";
import { Button } from "@/components/vin/button";
import { Field } from "@/components/vin/input";
import { Checkbox } from "@/components/vin/checkbox";
export function SheetBasic() {
return (
<Sheet
trigger={<Button variant="outline">Filters</Button>}
title="Filters"
description="Narrow the list of components."
onSubmit={(data) => console.log(Object.fromEntries(data))}
footer={
<>
<SheetClose><Button variant="outline">Cancel</Button></SheetClose>
<Button type="submit" value="apply">Show results</Button>
</>
}
>
<Field label="Search" name="q" type="search" placeholder="Button, card…" />
<Checkbox label="Forms" name="forms" defaultChecked />
<Checkbox label="Overlays" name="overlays" />
</Sheet>
);
}The Vue version renders the same markup as the HTML tab, so it looks and works the same.
<script setup lang="ts">
import Sheet, { SheetClose } from "@/components/vin/sheet.vue";
import Button from "@/components/vin/button.vue";
import Checkbox from "@/components/vin/checkbox.vue";
import Field from "@/components/vin/input.vue";
const onApply = (data: FormData) => console.log(Object.fromEntries(data));
</script>
<template>
<Sheet title="Filters" description="Narrow the list of components." @submit="onApply">
<template #trigger><Button variant="outline">Filters</Button></template>
<Field label="Search" name="q" type="search" placeholder="Button, card…" />
<Checkbox label="Forms" name="forms" default-checked />
<Checkbox label="Overlays" name="overlays" />
<template #footer>
<SheetClose><Button variant="outline">Cancel</Button></SheetClose>
<Button type="submit" value="apply">Show results</Button>
</template>
</Sheet>
</template>The Svelte version renders the same markup as the HTML tab, so it looks and works the same.
<script lang="ts">
import Sheet from "$lib/components/vin/sheet.svelte";
import Button from "$lib/components/vin/button.svelte";
import Field from "$lib/components/vin/input-field.svelte";
import Checkbox from "$lib/components/vin/checkbox.svelte";
</script>
<Sheet title="Filters" description="Narrow the list of components." onSubmit={(data) => console.log(Object.fromEntries(data))}>
{#snippet trigger(props)}<Button variant="outline" {...props}>Filters</Button>{/snippet}
<Field label="Search" name="q" type="search" placeholder="Button, card…" />
<Checkbox label="Forms" name="forms" checked />
<Checkbox label="Overlays" name="overlays" />
{#snippet footer(close)}
<Button variant="outline" onclick={close}>Cancel</Button>
<Button type="submit" value="apply">Show results</Button>
{/snippet}
</Sheet>Navigation
Site links from the left, as a mobile menu.
<button type="button" class="vin-btn vin-btn--outline" commandfor="sheet-nav" command="show-modal">Menu</button>
<dialog class="vin-dialog vin-sheet" id="sheet-nav" data-side="left" aria-labelledby="sheet-nav-title" closedby="any">
<div class="vin-dialog__header">
<h2 class="vin-dialog__title" id="sheet-nav-title">VinUI</h2>
</div>
<div class="vin-dialog__body">
<nav aria-label="Main" style="display: grid; gap: 12px">
<a class="vin-link" href="#docs">Docs</a>
<a class="vin-link" href="#components">Components</a>
<a class="vin-link" href="#styles">Styles</a>
<a class="vin-link" href="#changelog">Changelog</a>
</nav>
</div>
<button type="button" class="vin-btn vin-btn--ghost vin-btn--icon vin-dialog__close" commandfor="sheet-nav" command="close" aria-label="Close"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg></button>
</dialog>import { Sheet } from "@/components/vin/sheet";
import { Button } from "@/components/vin/button";
import { Link } from "@/components/vin/typography";
export function SheetLeft() {
return (
<Sheet side="left" trigger={<Button variant="outline">Menu</Button>} title="VinUI">
<nav aria-label="Main" style={{ display: "grid", gap: 12 }}>
<Link href="#docs">Docs</Link>
<Link href="#components">Components</Link>
<Link href="#styles">Styles</Link>
<Link href="#changelog">Changelog</Link>
</nav>
</Sheet>
);
}The Vue version renders the same markup as the HTML tab, so it looks and works the same.
<script setup lang="ts">
import Sheet from "@/components/vin/sheet.vue";
import Button from "@/components/vin/button.vue";
import { Link } from "@/components/vin/typography.vue";
</script>
<template>
<Sheet side="left" title="VinUI">
<template #trigger><Button variant="outline">Menu</Button></template>
<nav aria-label="Main" style="display: grid; gap: 12px">
<Link href="#docs">Docs</Link>
<Link href="#components">Components</Link>
<Link href="#styles">Styles</Link>
<Link href="#changelog">Changelog</Link>
</nav>
</Sheet>
</template>The Svelte version renders the same markup as the HTML tab, so it looks and works the same.
<script lang="ts">
import Sheet from "$lib/components/vin/sheet.svelte";
import Button from "$lib/components/vin/button.svelte";
import Link from "$lib/components/vin/typography-link.svelte";
</script>
<Sheet side="left" title="VinUI">
{#snippet trigger(props)}<Button variant="outline" {...props}>Menu</Button>{/snippet}
<nav aria-label="Main" style="display: grid; gap: 12px">
<Link href="#docs">Docs</Link>
<Link href="#components">Components</Link>
<Link href="#styles">Styles</Link>
<Link href="#changelog">Changelog</Link>
</nav>
</Sheet>From the bottom
A short panel that comes up from the bottom edge.
<button type="button" class="vin-btn vin-btn--outline" commandfor="sheet-share" command="show-modal">Share</button>
<dialog class="vin-dialog vin-sheet" id="sheet-share" data-side="bottom" aria-labelledby="sheet-share-title" aria-describedby="sheet-share-desc" closedby="any">
<div class="vin-dialog__header">
<h2 class="vin-dialog__title" id="sheet-share-title">Share this page</h2>
<p class="vin-dialog__description" id="sheet-share-desc">Anyone with the link can view it.</p>
</div>
<div class="vin-dialog__body">
<div class="vin-field">
<label class="vin-label" for="sheet-link">Link</label>
<input id="sheet-link" class="vin-input" value="https://vinish.dev/ui" readonly>
</div>
</div>
<button type="button" class="vin-btn vin-btn--ghost vin-btn--icon vin-dialog__close" commandfor="sheet-share" command="close" aria-label="Close"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg></button>
</dialog>import { Sheet } from "@/components/vin/sheet";
import { Button } from "@/components/vin/button";
import { Field } from "@/components/vin/input";
export function SheetBottom() {
return (
<Sheet side="bottom" trigger={<Button variant="outline">Share</Button>} title="Share this page" description="Anyone with the link can view it.">
<Field label="Link" defaultValue="https://vinish.dev/ui" readOnly />
</Sheet>
);
}The Vue version renders the same markup as the HTML tab, so it looks and works the same.
<script setup lang="ts">
import Sheet from "@/components/vin/sheet.vue";
import Button from "@/components/vin/button.vue";
import Field from "@/components/vin/input.vue";
</script>
<template>
<Sheet side="bottom" title="Share this page" description="Anyone with the link can view it.">
<template #trigger><Button variant="outline">Share</Button></template>
<Field label="Link" default-value="https://vinish.dev/ui" readonly />
</Sheet>
</template>The Svelte version renders the same markup as the HTML tab, so it looks and works the same.
<script lang="ts">
import Sheet from "$lib/components/vin/sheet.svelte";
import Button from "$lib/components/vin/button.svelte";
import Field from "$lib/components/vin/input-field.svelte";
</script>
<Sheet side="bottom" title="Share this page" description="Anyone with the link can view it.">
{#snippet trigger(props)}<Button variant="outline" {...props}>Share</Button>{/snippet}
<Field label="Link" value="https://vinish.dev/ui" readonly />
</Sheet>Installation
React, Vue and Svelte: add the component to your project with the CLI. It reads your framework from vin.json and also copies any component this one needs. Then import it:
npx @vinish/ui add sheetimport { Sheet, SheetClose } from "@/components/vin/sheet";import Sheet, { SheetClose } from "@/components/vin/sheet.vue";import Sheet from "$lib/components/vin/sheet.svelte";The import paths assume the default folders: @/components/vin (React and Vue, with the usual @ → src alias) and $lib/components/vin (SvelteKit). Use your own if you chose another folder in init. How the Vue and Svelte versions pass values and content is in Frameworks.
Plain HTML: the classes come with the style's stylesheet. It needs no JavaScript.
API
From spec/sheet.json, which every framework version is tested against.
| Prop | Values | Default | In HTML |
|---|---|---|---|
side | rightlefttopbottom | right | data-side on the dialog |
trigger / title / description / footerThe same as Dialog. | boolean | — | the Dialog parts inside dialog.vin-dialog.vin-sheet |
open / defaultOpenUse onOpenChange to hear about changes. | boolean | — | — |
onSubmitWraps the body and footer in a form. | (data: FormData) => void | — | form[method=dialog] |
Parts
| React, Vue, Svelte | HTML classes |
|---|---|
<Sheet><SheetClose> | .vin-sheet |
Accessibility
- It's a modal <dialog>, so it works like Dialog: focus stays inside, Escape closes it, focus goes back to the trigger.
- A click on the dimmed page closes it.
- In right-to-left pages the right sheet comes from the left, and the other way round.
- With reduced motion, it fades in instead of sliding.
Customize
Saved in this browser. Style and accent are in the header.