Open a panel from the edge of a page for a task that needs more room than a popover.
Sheet example
Example.jsx
import { Sheet } from "./ui/sheet";
import "./example.css";
export default function* Example() {
let open = false,
ink = "Carbon";
for (;;)
yield (
<section class="sample">
<h2>Cover specifications</h2>
<output>Selected ink · {ink}</output>
<button onClick={() => (open = true)}>Choose cover ink</button>
<Sheet
open={[() => open, (v) => (open = v)]}
title="Cover inks"
description="Choose an ink for the next proof."
>
<div class="actions">
{["Carbon", "Sea green", "Prussian blue"].map((color) => (
<button
key={color}
onClick={() => {
ink = color;
open = false;
}}
>
{color}
</button>
))}
</div>
</Sheet>
</section>
);
}
example.css
@media screen and (prefers-reduced-motion: no-preference) {
#example button:is(.v-primary, .v-secondary):enabled {
transition: transform 120ms ease-out;
}
#example button:is(.v-primary, .v-secondary):enabled:active {
transform: scale(0.98);
}
}
@media (prefers-reduced-motion: reduce) {
#example button:is(.v-primary, .v-secondary):enabled:active {
transition: none;
transform: none;
}
}
* {
box-sizing: border-box;
}
:root {
--example-seed: var(--aster-primary);
--example-secondary-text: var(--aster-on-surface-subtle);
}
body {
--aster-primary: color-mix(in srgb, var(--example-seed) 84%, var(--aster-on-surface));
--aster-on-surface-subtle: color-mix(in srgb, var(--example-secondary-text) 84%, var(--aster-on-surface));
--aster-input-border: color-mix(in srgb, var(--aster-on-surface) 55%, var(--aster-surface));
margin: 0;
padding: clamp(0.8rem, 4vw, 1.5rem);
color: var(--aster-on-surface);
background: var(--aster-surface-muted);
font: 1rem/1.5 var(--aster-font-sans);
}
#example {
display: grid;
gap: 0.8rem;
min-width: 0;
align-content: start;
}
#example > button,
.sample > button {
justify-self: start;
}
.sample,
.tile {
background: var(--aster-surface);
border: 1px solid var(--aster-border);
border-radius: var(--aster-radius-lg);
}
.sample {
display: grid;
gap: 0.8rem;
padding: clamp(0.85rem, 3vw, 1.35rem);
box-shadow: var(--aster-shadow-xs);
min-width: 0;
}
.tile {
padding: 1rem;
min-width: 0;
}
h2,
h3,
p,
dl,
ul {
margin-block: 0;
}
h2,
h3 {
letter-spacing: -0.025em;
line-height: 1.2;
}
h2 {
font-size: 1.25rem;
}
h3 {
font-size: 1rem;
}
.sample > header,
.identity > div,
.receipt {
display: grid;
gap: 0.25rem;
}
.sample > header p,
.tile p,
small {
color: var(--aster-on-surface-muted);
}
small {
font-size: 0.82rem;
}
.split,
.actions,
.identity {
display: flex;
align-items: center;
gap: 0.65rem;
flex-wrap: wrap;
}
.split {
justify-content: space-between;
padding-block: 0.4rem;
border-bottom: 1px solid var(--aster-border);
}
.split:last-child {
border-bottom: 0;
}
.metric {
font-size: 2rem;
letter-spacing: -0.06em;
}
.facts {
display: grid;
grid-template-columns: max-content 1fr;
gap: 0.45rem 1rem;
}
.facts dt {
color: var(--aster-on-surface-muted);
}
.facts dd {
margin: 0;
font-weight: 600;
}
.type-sample {
font:
2rem/1.2 Georgia,
serif;
}
.listing {
padding-inline-start: 1.25rem;
}
.ink-strip {
height: 1.2rem;
background: var(--aster-primary);
border-radius: var(--aster-radius-sm);
}
.ink-proof {
display: grid;
gap: 0.15rem;
border-left: 0.6rem solid;
padding-left: 0.8rem;
}
.ink-proof strong {
font-size: 1.25rem;
letter-spacing: 0.06em;
}
.glyph {
display: inline-grid;
place-items: center;
width: 2rem;
height: 2rem;
border-radius: var(--aster-radius-sm);
color: var(--aster-on-primary-subtle);
background: var(--aster-primary-subtle);
}
.cover-box {
width: min(100%, 18rem);
}
.cover {
display: flex;
min-height: 7.5rem;
height: 100%;
padding: 1rem 1.25rem;
flex-direction: column;
justify-content: space-between;
gap: 1.6rem;
color: #fff;
background: repeating-linear-gradient(150deg, transparent 0 8px, #fff2 8px 9px), #204a48;
}
.cover strong {
font:
italic 2.45rem/1 Georgia,
serif;
}
.cover span {
font: 0.78rem var(--aster-font-mono);
}
.cover.grove {
background-color: #3d4b27;
}
.cover.dune {
background-color: #7c4428;
}
button:not([class]),
.entry {
font: inherit;
font-size: 0.875rem;
padding: 0.45rem 0.8rem;
border: 1px solid var(--aster-border-strong);
border-radius: var(--aster-radius-control);
background: var(--aster-surface);
color: var(--aster-on-surface);
}
button:not([class]) {
cursor: pointer;
font-weight: 600;
}
button:not([class]):hover:enabled {
background: var(--aster-primary-subtle);
}
button:disabled {
cursor: default;
}
:focus-visible {
outline: 2px solid var(--aster-primary);
outline-offset: 3px;
}
output:not(:empty) {
display: block;
color: var(--aster-on-primary-subtle);
font-weight: 600;
font-size: 0.9rem;
}
Site-owned component source and scoped styles
src/ui/sheet
import './theme.css';
import { X } from '@lucide/icons';
import { scope, type View } from '@fierst/aster';
import { Icon } from './icon';
const sheetScope = scope`
:scope {
margin: 0;
padding: 0;
color: var(--aster-on-surface);
max-width: none;
max-height: none;
overflow: hidden;
overscroll-behavior: contain;
opacity: 1;
transition:
opacity var(--aster-dur-med) var(--aster-ease-standard),
transform var(--aster-dur-slow) var(--aster-ease-motion),
display var(--aster-dur-med),
overlay var(--aster-dur-med);
transition-behavior: allow-discrete;
}
:scope[open] { display: flex; flex-direction: column; }
:scope:not([open]) { display: none; }
:scope::backdrop {
background: rgba(0, 0, 0, 0.5);
backdrop-filter: blur(2px);
-webkit-backdrop-filter: blur(2px);
}
:scope.side-right {
margin-left: auto;
height: 100dvh;
width: 100vw;
border-radius: 0;
border-top: none;
border-right: none;
border-bottom: none;
transform: translateX(0);
}
:scope.side-left {
margin-right: auto;
height: 100dvh;
width: 100vw;
border-radius: 0;
border-top: none;
border-left: none;
border-bottom: none;
transform: translateX(0);
}
:scope.side-bottom {
margin: auto auto 0 auto;
width: 100vw;
height: fit-content;
max-height: 85dvh;
border-radius: var(--aster-radius-lg) var(--aster-radius-lg) 0 0;
border-left: none;
border-right: none;
border-bottom: none;
padding-bottom: var(--aster-safe-bottom);
transform: translateY(0);
}
@media (min-width: 640px) {
:scope.side-right,
:scope.side-left {
width: min(420px, 90vw);
}
:scope.side-bottom {
width: min(560px, calc(100vw - 2rem));
border-left: 1px solid var(--aster-border);
border-right: 1px solid var(--aster-border);
}
}
@starting-style {
:scope.side-right[open] { opacity: 0; transform: translateX(36px); }
:scope.side-left[open] { opacity: 0; transform: translateX(-36px); }
:scope.side-bottom[open] { opacity: 0; transform: translateY(36px); }
}
.grabber {
width: 36px;
height: 4px;
border-radius: 9999px;
background: var(--aster-border-strong);
margin: 0.6rem auto 0;
flex-shrink: 0;
}
.sheet-header {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 1rem;
padding: 1.15rem 1.25rem 0.95rem;
border-bottom: 1px solid var(--aster-border);
flex-shrink: 0;
}
.sheet-title {
margin: 0;
font-family: var(--aster-font-display);
font-size: 1.05rem;
font-weight: 600;
letter-spacing: -0.015em;
}
.sheet-desc {
margin: 0.2rem 0 0;
font-size: 0.85rem;
color: var(--aster-on-surface-muted);
}
.sheet-close {
width: 32px;
height: 32px;
border-radius: var(--aster-radius-sm);
border: none;
background: transparent;
color: var(--aster-on-surface-muted);
display: inline-grid;
place-items: center;
cursor: pointer;
flex-shrink: 0;
transition: background-color var(--aster-dur-fast), color var(--aster-dur-fast);
}
.sheet-close:hover { background: var(--aster-surface-muted); color: var(--aster-on-surface); }
.sheet-body {
flex: 1 1 auto;
min-height: 0;
overflow-y: auto;
overscroll-behavior: contain;
-webkit-overflow-scrolling: touch;
padding: 1.25rem;
display: flex;
flex-direction: column;
gap: 1rem;
}
.sheet-body > * { flex-shrink: 0; }
.sheet-footer {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: flex-end;
gap: 0.5rem;
padding: 0.9rem 1.25rem calc(0.9rem + var(--aster-safe-bottom));
background: var(--aster-surface-muted);
border-top: 1px solid var(--aster-border);
flex-shrink: 0;
}
`;
export type SheetSide = 'right' | 'left' | 'bottom';
export function Sheet({
id,
open,
side = 'right',
title,
description,
footer,
onClose,
class: extraClass,
children,
}: {
id?: string;
open?: any;
side?: SheetSide;
title?: string;
description?: string;
footer?: View;
onClose?: () => void;
class?: string;
children?: View;
}) {
let dialogEl: HTMLDialogElement | null = null;
const getOpen = () =>
Array.isArray(open)
? Boolean(open[0]?.())
: typeof open === 'function'
? Boolean(open())
: Boolean(open);
const setOpen = (v: boolean) => {
if (Array.isArray(open)) open[1]?.(v);
else open?.set?.(v);
};
const closeSheet = () => {
setOpen(false);
dialogEl?.close?.();
};
const onBackdropClick = (e: MouseEvent) => {
if (e.target === e.currentTarget) {
closeSheet();
}
};
return (
<dialog
aria-label={title ?? 'Panel'}
id={id}
ref={(el: Element) => {
dialogEl = el as HTMLDialogElement;
}}
bind:open={[getOpen, setOpen]}
closedby="any"
onClick={onBackdropClick}
onClose={onClose}
class={['aster-surface-popover', sheetScope, `side-${side}`, extraClass]
.filter(Boolean)
.join(' ')}
>
{side === 'bottom' ? <div class="grabber" aria-hidden="true" /> : null}
{title || description ? (
<header class="sheet-header">
<div>
{title ? <h2 class="sheet-title">{title}</h2> : null}
{description ? <p class="sheet-desc">{description}</p> : null}
</div>
<button type="button" class="sheet-close" aria-label="Close sheet" onClick={closeSheet}>
<Icon icon={X} size={16} />
</button>
</header>
) : null}
<div class="sheet-body">{children}</div>
{footer ? <footer class="sheet-footer">{footer}</footer> : null}
</dialog>
);
}
Install
sh
npx @fierst/ui@1.0.2 add sheetRegistry dependencies: theme, icon. Package dependencies: @lucide/icons.
Exports from ./ui/sheet: SheetSide, Sheet.
Download the registry source for sheet 1.0.2.
API contracts
ts
export type SheetSide = 'right' | 'left' | 'bottom';
export function Sheet({
id,
open,
side = 'right',
title,
description,
footer,
onClose,
class: extraClass,
children,
}: {
id?: string;
open?: any;
side?: SheetSide;
title?: string;
description?: string;
footer?: View;
onClose?: () => void;
class?: string;
children?: View;
})