Skip to content
iv-ui v0.3.0

Sheet

since 0.1.0

A panel that slides in from an edge for secondary flows.

import { Sheet } from '@elluzion/iv-ui';

Sides

One sheet that slides in from any of the four edges.

Source· svelte Show Hide
<script lang="ts">
	import type { SheetSide } from '@elluzion/iv-ui';
	import { Button, Sheet } from '@elluzion/iv-ui';

	let open = $state(false);
	let side = $state<SheetSide>('right');
</script>

<div class="stack">
	<div class="row">
		{#each ['left', 'right', 'top', 'bottom'] as edge (edge)}
			<Button
				size="sm"
				variant="outline"
				onclick={() => {
					side = edge as SheetSide;
					open = true;
				}}>{edge}</Button
			>
		{/each}
	</div>
	<Sheet bind:open {side} title="Sheet from the {side}">
		<p class="body">The panel slides in from the chosen edge and traps focus until it closes.</p>
	</Sheet>
</div>

<style>
	.stack {
		display: flex;
		flex-direction: column;
		align-items: center;
		gap: var(--iv_spacing-md);
	}

	.row {
		display: flex;
		flex-wrap: wrap;
		justify-content: center;
		gap: var(--iv_spacing-sm);
	}

	.body {
		margin: 0;
		color: var(--iv_foreground-dim);
		font-size: var(--iv_text-body);
	}
</style>
  • side chooses the edge; size sets the width, or the height for top and bottom sheets.
  • Bind open; the component closes itself and calls onclose when dismissed.
  • Use for filters, details, or compact forms; use Dialog for a decision.

Sizes

sm, md, lg, and full width steps.

Source· svelte Show Hide
<script lang="ts">
	import type { SheetSize } from '@elluzion/iv-ui';
	import { Button, Sheet } from '@elluzion/iv-ui';

	let open = $state(false);
	let size = $state<SheetSize>('md');
</script>

<div class="stack">
	<div class="row">
		{#each ['sm', 'md', 'lg', 'full'] as step (step)}
			<Button
				size="sm"
				variant={size === step ? 'primary' : 'outline'}
				onclick={() => {
					size = step as SheetSize;
					open = true;
				}}>{step}</Button
			>
		{/each}
	</div>
	<Sheet bind:open {size} title="Size {size}" side="right">
		<p class="body">Width is capped by the size step; full takes the whole viewport.</p>
	</Sheet>
</div>

<style>
	.stack {
		display: flex;
		flex-direction: column;
		align-items: center;
		gap: var(--iv_spacing-md);
	}

	.row {
		display: flex;
		flex-wrap: wrap;
		justify-content: center;
		gap: var(--iv_spacing-sm);
	}

	.body {
		margin: 0;
		color: var(--iv_foreground-dim);
		font-size: var(--iv_text-body);
	}
</style>

Footer

A sticky footer keeps the actions in reach.

Source· svelte Show Hide
<script lang="ts">
	import { Button, Field, Input, Sheet } from '@elluzion/iv-ui';

	let open = $state(false);
	let name = $state('Orbital');
	let saved = $state(false);
</script>

<div class="stack">
	<Button onclick={() => (open = true)}>Edit workspace</Button>
	<Sheet bind:open title="Workspace" side="right">
		<Field label="Name" htmlFor="sheet-name">
			<Input id="sheet-name" bind:value={name} />
		</Field>
		{#snippet footer()}
			<Button variant="ghost" onclick={() => (open = false)}>Cancel</Button>
			<Button
				variant="primary"
				onclick={() => {
					open = false;
					saved = true;
				}}>Save</Button
			>
		{/snippet}
	</Sheet>
	{#if saved}<p class="readout">saved {name}</p>{/if}
</div>

<style>
	.stack {
		display: flex;
		flex-direction: column;
		align-items: center;
		gap: var(--iv_spacing-sm);
	}

	.readout {
		margin: 0;
		font-family: var(--iv_font-mono);
		font-size: var(--iv_text-sm);
		color: var(--iv_success);
	}
</style>
import { Sheet } from '@elluzion/iv-ui';

Props

8 props · 1 events · 3 snippets
PropTypeDefaultDescription
open required bindablebooleanfalseWhether the sheet is visible. Bind with bind:open.
side SheetSide'bottom'Edge the sheet slides in from.
size SheetSize'md'Sheet width (or height for top/bottom sheets).
title string''Sheet title; also used as the accessible name.
closeOnBackdrop booleantrueCloses when the backdrop is clicked.
closeOnEscape booleantrueCloses on Escape.
showCloseButton booleantrueShows the header close button.
className string''Extra classes merged onto the root element.

class, id, style, aria-*, and data-* are forwarded through rest props.

Events

EventHandler typeDescription
onclose() => voidCalled when the sheet requests to close; set open = false in response.

The legacy on:name form is accepted for every event.

Snippets

SnippetTypeDescription
childrenSnippetContent rendered inside the component.
iconSnippetIcon rendered before the title.
footerSnippetActions rendered below the body.

Types

SheetSide

Edge the sheet slides in from.

type SheetSide = 'left' | 'right' | 'top' | 'bottom';
SheetSize

Sheet width or height step.

type SheetSize = 'sm' | 'md' | 'lg' | 'full';
KeysAction
TabCycles focus inside the sheet.
EscapeCloses the sheet unless closeOnEscape is false.
  • The surface uses role="dialog" and aria-modal="true".
  • The title names the sheet; the body is linked through aria-describedby.
  • Focus is trapped while open and restored on close.
Class hooks
.iv-backdrop.iv-body.iv-body-no-title.iv-close-btn.iv-footer.iv-header.iv-icon-slot.iv-sheet.iv-sheet-full.iv-sheet-lg.iv-sheet-sm.iv-side-bottom.iv-side-left.iv-side-right.iv-side-top.iv-title-area
iv-ui
↑ ↓ navigate ↵ open esc close minisearch · 482 records