component
Sheet
A panel that slides over the page from the right, for a task with more to it than a dialog: editing a client, an invoice's details.
Try it
Every variant
Edit client
Defaultimport { Sheet } from 'rost/components/sheet/Sheet'
<Sheet open={editing} onClose={() => setEditing(false)} title="Edit client"
actions={<><Button variant="secondary" onClick={() => setEditing(false)}>Cancel</Button><Button onClick={save}>Save</Button></>}>
<ClientForm />
</Sheet> src/components/sheet/Sheet.tsx
import { useEffect, useId, useRef, type HTMLAttributes, type ReactNode } from 'react'
import './sheet.css'
export interface SheetProps extends Omit<HTMLAttributes<HTMLDialogElement>, 'title'> {
/** Shows it as a modal. */
readonly open?: boolean
/** What it asks or what it's for. */
readonly title: ReactNode
/** Its Buttons, the main one last. */
readonly actions?: ReactNode
/** Called when it closes, by Esc or otherwise. */
readonly onClose?: () => void
/** Draws the plate in place, without the modal, for previews. */
readonly preview?: boolean
readonly children?: ReactNode
}
const b = 'rost-sheet'
/**
* A panel over the page from the right edge, full height. The browser's
* `<dialog>`, opened with `showModal()`, so focus, Esc and the page behind
* are the browser's. Built from contracts/sheet.contract.yaml.
*/
export function Sheet({ open = false, title, actions, onClose, preview = false, children, className, ...rest }: SheetProps) {
const ref = useRef<HTMLDialogElement>(null)
const titleId = useId()
useEffect(() => {
const d = ref.current
if (!d || preview) return
if (open && !d.open) d.showModal()
if (!open && d.open) d.close()
}, [open, preview])
const panel = (
<div className={`${b}__panel`}>
<h2 id={titleId} className={`${b}__title`}>{title}</h2>
{children != null && <div className={`${b}__body`}>{children}</div>}
{actions != null && <div className={`${b}__actions`}>{actions}</div>}
</div>
)
const cls = [b, className].filter(Boolean).join(' ')
if (preview) return <div className={cls} role="dialog" aria-labelledby={titleId}>{panel}</div>
return <dialog ref={ref} className={cls} aria-labelledby={titleId} onClose={onClose} {...rest}>{panel}</dialog>
}
The source for everything on this page: contracts/sheet.contract.yaml (opens in a new tab). The CSS, the docs and the checks in each app are built from it.
# yaml-language-server: $schema=../schema/component-contract.schema.json
schemaVersion: 2
id: sheet
name: Sheet
kind: component
status: review
summary: "A panel that slides over the page from the right, for a task with more to it than a dialog: editing a client, an invoice's details."
category: surfaces
related: [ dialog, popover ]
source:
tool: figma
fileKey: 1Zy0wiWKXQAvsfDBX3KR0d
nodeId: "744:3"
url: https://www.figma.com/design/1Zy0wiWKXQAvsfDBX3KR0d/UI-Kit-v01?node-id=744-3
extractedAt: "2026-11-16"
extractedBy: hand
frozenAt: "2026-11-16"
props:
open: { type: boolean, default: false, notes: "Shows it as a modal, with `showModal()`." }
title: { type: slot, required: true, notes: "What it's for. It names the sheet." }
children: { type: slot, notes: "A form or details. It scrolls when it's taller than the window." }
actions: { type: slot, notes: "Its Buttons, at the bottom, the main one last." }
elements:
root:
notes: "The browser's `<dialog>`, its own look taken away and moved to the window's right edge, full height."
styles:
padding: { token: spacing/gap/none, value: 0px }
border: { value: none, assert: false }
background: { value: transparent, assert: false }
color: { value: inherit, assert: false }
margin: { value: "0 0 0 auto", assert: false, notes: "Against the right edge instead of the middle." }
block-size: { value: 100%, assert: false, notes: "A modal dialog sits in the window, so this is the window's full height." }
max-height: { value: none, assert: false }
max-width: { value: none, assert: false }
backdrop:
pseudo: "::backdrop"
notes: "The page behind, dimmed to 72% of its own colour, as Dialog's is."
styles:
background: { token: sheet/backdrop, value: "#060805" }
opacity: { token: opacity/hard, value: "0.72" }
panel:
notes: "The plate: the full height, 400px wide, the title at the top and the buttons pinned to the bottom."
styles:
display: { value: flex, assert: false }
flex-direction: { value: column, assert: false }
gap: { token: spacing/gap/medium, value: 16px }
width: { value: 400px, notes: "A form's width. On a phone it's the screen less 16px." }
max-width: { value: calc(100vw - 16px), assert: false }
height: { value: 100%, assert: false }
padding: { token: spacing/gap/large, value: 24px }
background: { token: sheet/background, value: "#171717" }
outline-style: { value: solid, assert: false }
outline-width: { token: spacing/outline/small, value: 1px }
outline-offset: { value: "calc(-1 * var(--spacing-outline-small))", untokenised: "Composed from a token: the edge sits inside." }
outline-color: { token: sheet/edge, value: "#3a3a3a" }
box-shadow: { token: shadow/floating, value: "0px 16px 24px 0px rgba(0, 0, 0, 0.16)" }
title:
notes: "An `<h2>` in title type, medium weight."
styles:
font-family: { token: font-family/base, value: "'General Sans Variable'" }
font-weight: { token: typography/title/font-weight/medium, value: "500" }
font-size: { token: typography/title/font-size, value: 24px }
line-height: { token: typography/title/line-height, value: 32px }
letter-spacing: { token: typography/title/letter-spacing, value: 0px }
color: { token: sheet/title, value: "#ededed" }
body:
notes: "Paragraph type. It takes the room there is and scrolls."
styles:
flex-grow: { value: "1", assert: false }
overflow-y: { value: auto, assert: false }
font-family: { token: font-family/base, value: "'General Sans Variable'" }
font-weight: { token: typography/paragraph/font-weight/regular, value: "400" }
font-size: { token: typography/paragraph/font-size, value: 14px }
line-height: { token: typography/paragraph/line-height, value: 20px }
letter-spacing: { token: typography/paragraph/letter-spacing, value: 0px }
color: { token: sheet/body, value: "#d3d9d5" }
actions:
notes: "The Buttons in a row on the right, 8px apart, at the bottom."
styles:
display: { value: flex, assert: false }
justify-content: { value: flex-end }
gap: { token: spacing/gap/small, value: 8px }
guidance:
status: proposed
use:
- title: A task beside the page
text: "Editing something from a list without leaving it: a client, an invoice's details. The list stays in sight behind it."
avoid:
- title: A quick question
text: "Yes or no, or two fields. That's **Dialog**."
- title: A whole job
text: "Something that takes several screens. Give it a page."
behaviour: |-
It's a `<dialog>` opened as a modal and moved to the right edge, full height: the browser does focus, Esc and the page behind. The page dims as it does for Dialog. It doesn't slide in yet; it appears.
accessibility:
element: "`<dialog>` opened with `showModal()`, labelled by its title."
name: "The title."
keyboard: "Focus starts inside and stays there until it closes. Esc closes it."
focus: "When it closes, focus goes back to what opened it."
colour: "The title is 14:1 and the words 11:1 on the plate, in dark."
content: "The title says what's being done (Edit client); the buttons say how it ends (Cancel, Save)."
Install
npx github:Runceanu/rost add sheet It lands in src/rost/sheet/, with what it needs and its contract. Install has the rest.
When to use
A task beside the page
Editing something from a list without leaving it: a client, an invoice's details. The list stays in sight behind it.
When not to use
A quick question
Yes or no, or two fields. That's Dialog.
A whole job
Something that takes several screens. Give it a page.
Behaviour
It's a <dialog> opened as a modal and moved to the right edge, full height: the browser does focus, Esc and the page behind. The page dims as it does for Dialog. It doesn't slide in yet; it appears.
Accessibility
- Element
<dialog>opened withshowModal(), labelled by its title. - Name
The title.
- Keyboard
Focus starts inside and stays there until it closes. Esc closes it.
- Focus
When it closes, focus goes back to what opened it.
- Colour
The title is 14:1 and the words 11:1 on the plate, in dark.
Content
The title says what's being done (Edit client); the buttons say how it ends (Cancel, Save).
Props
| Prop | Type | Values | Default |
|---|---|---|---|
open | boolean | | false |
title | slot | | |
children | slot | | |
actions | slot | | |
Values
Straight from the contract. Each value sits next to its token, because six tokens here all come out as #3a3a3a and the colour alone can't tell you which one is right.
Never changes
root
-
padding0pxspacing/gap/none
bordernone · backgroundtransparent · colorinherit · margin0 0 0 auto · block-size100% · max-heightnone · max-widthnone
backdrop
-
background#060805sheet/backdrop -
opacity0.72opacity/hard
panel
-
gap16pxspacing/gap/medium -
width400pxno token yet -
padding24pxspacing/gap/large -
background#171717sheet/background -
outline-width1pxspacing/outline/small -
outline-offsetcalc(-1 * var(--spacing-outline-small))on purpose: Composed from a token: the edge sits inside. -
outline-color#3a3a3asheet/edge -
box-shadow0px 16px 24px 0px rgba(0, 0, 0, 0.16)shadow/floating
displayflex · flex-directioncolumn · max-widthcalc(100vw - 16px) · height100% · outline-stylesolid
title
-
font-family'General Sans Variable'font-family/base -
font-weight500typography/title/font-weight/medium -
font-size24pxtypography/title/font-size -
line-height32pxtypography/title/line-height -
letter-spacing0pxtypography/title/letter-spacing -
color#edededsheet/title
body
-
font-family'General Sans Variable'font-family/base -
font-weight400typography/paragraph/font-weight/regular -
font-size14pxtypography/paragraph/font-size -
line-height20pxtypography/paragraph/line-height -
letter-spacing0pxtypography/paragraph/letter-spacing -
color#d3d9d5sheet/body
flex-grow1 · overflow-yauto
actions
-
gap8pxspacing/gap/small
displayflex · justify-contentflex-end