Skip to Content
CodeUI

Sheet

@codeui/solid v0.3.0

A panel attached to a viewport edge.

When to use

Sheet presents a panel over your content, including a phone panel or export options. Opening a sheet does not reflow the frame.

When to choose another component

Use Dialog for a blocking decision. Use Popover for a picker anchored to a control.

Live demo

sheet/basic.tsx
import { Button, Sheet } from "@codeui/solid";
import { createSignal, For } from "solid-js";

function Example(props: { side?: "left" | "right" | "bottom" }) {
	const [open, setOpen] = createSignal(false);
	return <>
		<Button variant="secondary" onClick={() => setOpen(true)}>Open {props.side ?? "export options"}</Button>
		<Sheet open={open()} onOpenChange={setOpen}  title="Export options" description="Choose how to share your snippet." closeLabel="Close export options"
			footer={<Button variant="primary" onClick={() => setOpen(false)}>Done</Button>}>
			<p>PNG preserves the frame background. SVG keeps text sharp at any size.</p>
		</Sheet>
	</>;
}
export default function Demo() {
	return <Example />;
}

Anatomy

Tap a part to outline it in the demo.

  1. 01Triggersheet-triggerclasses.trigger
  2. 02Overlaysheet-overlayclasses.overlay
  3. 03Contentsheet-contentclasses.content
  4. 04Handlesheet-handleclasses.handle
  5. 05Headersheet-headerclasses.header
  6. 06Titlesheet-titleclasses.title
  7. 07Descriptionsheet-descriptionclasses.description
  8. 08CloseButtonsheet-close-buttonclasses.closeButton
  9. 09Bodysheet-bodyclasses.body
  10. 10Footersheet-footerclasses.footer
ExportRendersclasses keydata-cuiRole
Rootnonenonenonenone
Portalnonenonenonenone
Triggerbuttontriggersheet-triggerbutton
Overlaydivoverlaysheet-overlaynone
Contentdivcontentsheet-contentdialog
Handlebuttonhandlesheet-handlebutton
Headerdivheadersheet-headernone
Titleh2titlesheet-titleheading
Descriptionpdescriptionsheet-descriptionnone
CloseButtonbuttoncloseButtonsheet-close-buttonbutton
Bodydivbodysheet-bodynone
Footerdivfootersheet-footernone

Variants

sheet/sides.tsx
import { Button, Sheet } from "@codeui/solid";
import { createSignal, For } from "solid-js";

function Example(props: { side?: "left" | "right" | "bottom" }) {
	const [open, setOpen] = createSignal(false);
	return <>
		<Button variant="secondary" onClick={() => setOpen(true)}>Open {props.side ?? "export options"}</Button>
		<Sheet open={open()} onOpenChange={setOpen} side={props.side} title="Export options" description="Choose how to share your snippet." closeLabel="Close export options"
			footer={<Button variant="primary" onClick={() => setOpen(false)}>Done</Button>}>
			<p>PNG preserves the frame background. SVG keeps text sharp at any size.</p>
		</Sheet>
	</>;
}
export default function Demo() {
	return <div style={{ display: "flex", gap: "var(--cui-space-3)", "flex-wrap": "wrap" }}><For each={["left", "right", "bottom"] satisfies ("left" | "right" | "bottom")[]}>{side => <Example side={side} />}</For></div>;
}

side accepts left, right, and bottom. Bottom is the default. A left or right sheet floats 8px in from the top, bottom and its edge, with every corner rounded, and is 24rem wide (set --cui-sheet-width on the content to change it). At 768px and below it becomes a bottom sheet.

In a container

Pass mount an element other than document.body, and the sheet and its scrim cover that element instead of the viewport. Give the element position: relative. CodeLoom mounts its side sheet in the content island, so the sidebar stays uncovered and usable.

Change what the sheet shows while it stays open, and it swaps in place with no close and reopen. For a nonmodal sheet beside a list, keep a click on another row from dismissing it: call event.preventDefault() in contentProps.onInteractOutside when the target is a row.

sheet/nonmodal.tsx
import { Button, Sheet } from "@codeui/solid";
import { createSignal, For } from "solid-js";

function Example(props: { side?: "left" | "right" | "bottom" }) {
	const [open, setOpen] = createSignal(false);
	return <>
		<Button variant="secondary" onClick={() => setOpen(true)}>Open {props.side ?? "export options"}</Button>
		<Sheet open={open()} onOpenChange={setOpen} modal={false} title="Export options" description="Choose how to share your snippet." closeLabel="Close export options"
			footer={<Button variant="primary" onClick={() => setOpen(false)}>Done</Button>}>
			<p>PNG preserves the frame background. SVG keeps text sharp at any size.</p>
		</Sheet>
	</>;
}
export default function Demo() {
	return <Example />;
}

Modal sheets render a scrim and trap focus. modal={false} removes the scrim and leaves the page interactive.

sheet/draggable.tsx
import { Button, Sheet } from "@codeui/solid";
import { createSignal, For } from "solid-js";

function Example(props: { side?: "left" | "right" | "bottom" }) {
	const [open, setOpen] = createSignal(false);
	return <>
		<Button variant="secondary" onClick={() => setOpen(true)}>Open {props.side ?? "export options"}</Button>
		<Sheet open={open()} onOpenChange={setOpen} draggable title="Export options" description="Choose how to share your snippet." closeLabel="Close export options"
			footer={<Button variant="primary" onClick={() => setOpen(false)}>Done</Button>}>
			<div style={{ "max-height": "160px", overflow: "auto" }}><For each={Array.from({ length: 20 }, (_, index) => `Snippet ${index + 1}.png`)}>{name => <p>{name}</p>}</For></div>
		</Sheet>
	</>;
}
export default function Demo() {
	return <Example />;
}

draggable adds a handle to a bottom sheet. A left or right sheet renders the handle only while it is a bottom sheet, at 768px and below.

sheet/motion.tsx
import { Button, Sheet } from "@codeui/solid";
import { createSignal, For } from "solid-js";

function Example(props: { side?: "left" | "right" | "bottom" }) {
	const [open, setOpen] = createSignal(false);
	return <>
		<Button variant="secondary" onClick={() => setOpen(true)}>Open {props.side ?? "export options"}</Button>
		<Sheet open={open()} onOpenChange={setOpen} motion="none" title="Export options" description="Choose how to share your snippet." closeLabel="Close export options"
			footer={<Button variant="primary" onClick={() => setOpen(false)}>Done</Button>}>
			<p>PNG preserves the frame background. SVG keeps text sharp at any size.</p>
		</Sheet>
	</>;
}
export default function Demo() {
	return <Example />;
}

motion="auto" slides on pointer open and close: in over 260ms on the drawer curve, out over 200ms ease-out. The slide is a CSS transition, so reopening a sheet mid-exit turns it around from where it is. Keyboard actions do not animate. Reduced motion replaces the slide with a fade. motion="none" disables presence animation.

A downward drag tracks the handle 1:1. Dragging above the open position applies rubber band resistance. A downward flick above 0.5 px/ms or a drag beyond 35% of the sheet height dismisses it. Short drags and pointercancel settle back open. A new grab can interrupt the settle. Reduced motion skips the settle animation.

Drag events belong to Handle, not Body. Scrollable body content scrolls without starting a dismiss gesture. The draggable demo includes a scroll region for this distinction.

States

The live demo controls open with onOpenChange. Parts also support defaultOpen for uncontrolled state. Closed content stays mounted until its exit transition ends, then unmounts unless forceMount is set. During the exit the sheet is inert and the page under it takes clicks.

Ready API

Sheet

Renders a portal, optional overlay, content, and the supplied title, description, body, and footer.

Prop

Type

Prop

Type

Styled parts API

Import parts from @codeui/solid/sheet/parts. Each export is a named function.

Root

Kobalte Dialog.Root with input-aware motion. It renders no DOM.

Prop

Type

Prop

Type

Content

Kobalte Dialog.Content with edge placement and focus return.

Prop

Type

Prop

Type

CloseButton

Kobalte Dialog.CloseButton rendered with the kit IconButton. Its default accessible name is "close".

Prop

Type

Prop

Type

Handle

A button that closes on click, Enter, or Space and supports drag dismissal. It requires Root and Content.

Prop

Type

Prop

Type

Body

A scrollable body div.

Prop

Type

A layout div for the title and close action.

Prop

Type

A div for actions at the end of the panel.

Prop

Type

Overlay

Kobalte Dialog.Overlay with scrim styles. Include it only for a modal sheet.

Prop

Type

Portal

Kobalte Dialog.Portal. mount selects the browser destination. It renders no wrapper. With a mount other than document.body, the overlay and the content get data-contained and cover that element.

Prop

Type

Prop

Type

Title

Kobalte Dialog.Title rendered as an h2.

Prop

Type

Description

Kobalte Dialog.Description rendered as a paragraph.

Prop

Type

Trigger

Kobalte Dialog.Trigger rendered as a button.

Prop

Type

Prop

Type

The remaining inherited props follow the Kobalte Sheet contract.

Styles export

sheetStyles

SheetStyles maps each anatomy part key to a function that returns its class string. Set data-side on custom content, for example data-side="bottom". trigger() returns an empty string. Import these functions from @codeui/solid/sheet/parts.

Accessibility

Keyboard

KeyAction
Enter or Space on triggerOpens the sheet.
EscapeCloses the innermost sheet.
Tab or Shift+TabMoves through focusable controls. Modal sheets keep focus inside.
Enter or Space on handle or close buttonCloses the sheet.

ARIA

Content has role="dialog", a title link through aria-labelledby, and a description link through aria-describedby. Modal content has aria-modal. Without a visible title, provide aria-label. Trigger exposes open state and the controlled content ID.

Focus

Opening moves focus into the sheet. Modal sheets trap focus. Closing returns focus to Trigger, or to the element focused before opening when no Trigger exists. A nonmodal outside interaction keeps focus on the outside target. contentProps can override autofocus through cancellable events.

SSR notes

Open or force-mounted sheets include their overlay and content in server HTML at the Portal declaration. Hydration adopts those nodes and moves them to the portal target. Closed content stays absent unless force-mounted. Input tracking starts on mount. Supply mount only after its element exists in the browser.

Theming hooks

Sheet reads --cui-surface-scrim, --cui-surface-dialog, --cui-text-dialog, --cui-text-dialog-title, --cui-shadow-dialog, --cui-border-width, --cui-border-dialog-title, --cui-radius-xl, --cui-radius-full, --cui-action-neutral-active, and --cui-text-muted. Layout uses --cui-space-1, -2, -3, -4, -6, and -10, with the same --cui-space prefix.

Typography uses --cui-font-size-lg, --cui-font-size-sm, --cui-font-weight-medium, and --cui-font-line-height-compact. Focus uses --cui-focus-width, --cui-focus-color, and --cui-focus-offset. Motion uses --cui-motion-duration-panel and --cui-motion-ease-out.

See Inkstone foundations for the design rules.

Composition examples

sheet/parts.tsx
import { Button } from "@codeui/solid";
import * as S from "@codeui/solid/sheet/parts";
export default function Demo() {
	return <S.Root modal={false}>
		<S.Trigger as={Button} variant="secondary">Open layers</S.Trigger>
		<S.Portal>
			<S.Content side="bottom">
				<S.Handle aria-label="Close layers" />
				<S.Header><S.Title>Layers</S.Title><S.CloseButton aria-label="Close layers" /></S.Header>
				<S.Description>Layers visible in the exported image.</S.Description>
				<S.Body><p>Background, window, code, and watermark.</p></S.Body>
				<S.Footer><S.CloseButton aria-label="Done with layers" /></S.Footer>
			</S.Content>
		</S.Portal>
	</S.Root>;
}

Parts compose a nonmodal layers panel without an Overlay.

sheet/docked.tsx
import { Button } from "@codeui/solid";
import * as S from "@codeui/solid/sheet/parts";
import { createSignal, Show } from "solid-js";
export default function Demo() {
	const [mount, setMount] = createSignal<HTMLDivElement>();
	return <S.Root modal={false}>
		<div style={{ position: "relative", height: "360px", width: "100%" }}>
			<S.Trigger as={Button} variant="secondary">Open docked layers</S.Trigger>
			<div ref={setMount} style={{ position: "absolute", inset: "48px 0 0" }} />
			<Show when={mount()}>{target => <S.Portal mount={target()}>
				<S.Content style={{ position: "absolute", "max-height": "100%" }}>
					<S.Handle aria-label="Close layers" />
					<S.Header><S.Title>Layers</S.Title><S.CloseButton aria-label="Close layers" /></S.Header>
					<S.Body>Background, window, code, and watermark.</S.Body>
				</S.Content>
			</S.Portal>}</Show>
		</div>
	</S.Root>;
}

For a docked panel, Portal accepts a layout mount and Content accepts positioning styles. The mount must exist before Portal renders.

Dialog presents blocking settings or decisions. Accordion groups settings within a sheet.

On this page