Skip to content

shadcn.io is an independent project built on shadcn/ui

Components

Free

Sheet for Solid

A side panel for Solid on Ark UI that slides in from any edge for filters, a cart or an edit form, and keeps focus inside until it closes.

On this page9 sections
UI library: Ark UI

A sheet is a dialog that slides in from one edge of the screen and runs its whole length, for work that needs more room than a centered window: a filter panel, a cart, an edit form next to the list it changes.

A short task fits a Dialog in the middle of the screen. On phones, where people expect to swipe a panel away, use a Drawer: a sheet has no gesture, and a button, Escape or a click outside closes it.

Preview width

Installation

Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.

Anatomy

Sheet anatomy: content, close, title, description, footer

Usage

import { Button } from "@/components/ui/button";
import { Field, FieldLabel } from "@/components/ui/field";
import { Input } from "@/components/ui/input";
import {
  Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter,
  SheetHeader, SheetTitle, SheetTrigger,
} from "@/components/ui/sheet";

The panel renders in a portal at the end of the page, so the <form> goes inside SheetContent, around the fields and the footer with its submit button.

<Sheet>
  <SheetTrigger
    asChild={(props) => (
      <Button {...props()} variant="outline">Open</Button>
    )}
  />
  <SheetContent>
    <SheetHeader>
      <SheetTitle>Edit profile</SheetTitle>
      <SheetDescription>
        Make changes to your profile here. Click save when you&apos;re done.
      </SheetDescription>
    </SheetHeader>
    <form class="contents">
      <div class="grid flex-1 auto-rows-min gap-6 px-4">
        <Field class="grid gap-3">
          <FieldLabel>Name</FieldLabel>
          <Input defaultValue="Pedro Duarte" name="name" type="text" />
        </Field>
        <Field class="grid gap-3">
          <FieldLabel>Username</FieldLabel>
          <Input defaultValue="@peduarte" name="username" type="text" />
        </Field>
      </div>
      <SheetFooter>
        <Button type="submit">Save changes</Button>
        <SheetClose
          asChild={(props) => (
            <Button {...props()} variant="outline">Close</Button>
          )}
        />
      </SheetFooter>
    </form>
  </SheetContent>
</Sheet>

Accessibility

The panel has role="dialog" and takes its name from SheetTitle, an h2. While it is open, focus stays inside it, the page behind is hidden from screen readers, and Escape closes it and returns focus to the trigger. Focus starts on the first focusable element inside, and SheetDescription is announced with the title. Give every sheet a title, hidden with sr-only when the design shows none.

Enter
When focus is on the trigger, opens the sheet.
Space
When focus is on the trigger, opens the sheet.
Tab
Moves focus to the next focusable element in the sheet, and from the last one back to the first.
Shift+Tab
Moves focus to the previous focusable element in the sheet, and from the first one to the last.
Escape
Closes the sheet and moves focus back to the trigger.

Demos

Side

Four buttons open the same edit profile sheet from the top, right, bottom and left, set with side on SheetContent, which defaults to right. Top and bottom sheets are capped at half the screen here, so the text scrolls between the header and the footer. Use a side for a form or an inspector beside a list, and the top or bottom for a short strip of options.

Preview width

No close button

Setting showCloseButton to false on SheetContent takes the corner X away. This sheet has nothing else to press, so its description tells people to click outside, and Escape closes it too. In a real sheet, hide the X only when the footer has its own Close or Done button.

Preview width

RTL

The edit profile form in Arabic, inside a Direction provider set to right to left, with side set to left on SheetContent. side names a physical edge, so it stays on the left. The provider sets the direction Ark UI gives every part, so the title, labels, fields and buttons follow it, and the corner X moves to the left, where an Arabic line ends.

Preview width

FAQ

When should I use a Sheet instead of a Dialog or a Drawer?

Use a Sheet when the task needs the full height of the screen and sits next to what it changes: filters beside a product grid, a cart, an edit form for a row in a table. It slides in from an edge and keeps part of the page in view.

A Dialog suits a short task in the middle of the screen. A Drawer follows a swipe and can stop at snap points, which is what phone users expect from a bottom panel.

How do I open a Sheet from the left, top or bottom?

Set side on SheetContent to left, top or bottom. The default is right. Left and right sheets run the full height of the screen, and top and bottom ones the full width, as tall as their content.

The value is a physical edge, so left stays on the left in a right-to-left page. The Side demo opens one from each edge.

How do I open and close a Sheet from code in Solid?

Hold the open state yourself: pass open to Sheet and update it in onOpenChange, which receives an object, so read details.open.

Then a row's Edit button, a keyboard shortcut or a route change can open it, and your code can close it after a save.

How do I submit a form in a Sheet and close it after saving?

Put the <form> inside SheetContent, around the fields and SheetFooter. The panel renders in a portal at the end of the page, so a form wrapped around the whole sheet doesn't contain its inputs, and the submit button in the footer does nothing.

Hold the open state yourself, and set it to closed in the submit handler once the save succeeds, so a failed save leaves the form open with its error. Keep the save off SheetClose, which closes the sheet before the request finishes.

How do I make a Sheet wider?

Left and right sheets take three quarters of the screen's width and stop at max-w-sm from the sm breakpoint up. That cap is written with a data-[side=right]: or data-[side=left]: prefix, so a plain sm:max-w-lg on the sheet loses to it. Repeat the prefix instead, as in data-[side=right]:sm:max-w-lg.

To widen every sheet, change the cap in your copy of the component. Below the sm breakpoint the width stays at three quarters, which leaves a strip of the page to tap to close it. Set variant to inset on SheetContent if the panel should float with a gap from the screen's edges, which it does from the sm breakpoint up.

How do I hide the close button in the corner of a Sheet?

Set showCloseButton to false on SheetContent, as in the No close button demo. Only the button goes: Escape and a click outside still close the sheet.

Put a SheetClose in the footer, labeled Close, Cancel or Done, so touch and screen reader users have something to press.

Does a Sheet need a SheetTitle?

Yes. SheetTitle names the panel, and a screen reader announces that name when focus moves in. Without it the panel has no name, and people hear only that a dialog opened.

When the design has no visible heading, keep SheetTitle and add the sr-only class to it. SheetDescription is optional, a line on what the panel is for.

How do I make a long Sheet scroll and keep its footer in view?

Keep SheetHeader and SheetFooter outside the part that scrolls, and let the middle take the rest of the height and scroll. SheetBody does that, as in the Side demo: it fills the space between the two with a scroll area, and scrollFade fades the text at its edges.

Top and bottom sheets grow with their content, so give them a maximum height too, as the demo does with half the screen.

API Reference

Sheet

data-slot="sheet"

PropType
open?boolean

The controlled open state of the dialog.

defaultOpen?boolean

The initial open state of the dialog when rendered. Use when you don't need to control the open state of the dialog.

Default
false
onOpenChange?(details: OpenChangeDetails) → void

Function to call when the dialog's open state changes.

Type
(details: OpenChangeDetails) → void
Parameters

details – { open: boolean }

Returns
void
triggerValue?string | null

The controlled active trigger value.

Type
string | null
defaultTriggerValue?string | null

The initial active trigger value when rendered. Use when you don't need to control the active trigger value.

Type
string | null
onTriggerValueChange?(details: TriggerValueChangeDetails) → void

Function to call when the active trigger changes.

Type
(details: TriggerValueChangeDetails) → void
Parameters

details – { value: string | null; triggerElement: HTMLElement | null }

Returns
void
closeOnEscape?boolean

Whether to close the dialog when the escape key is pressed.

Default
true
closeOnInteractOutside?boolean

Whether to close the dialog when the outside is clicked.

Default
true
dir?"ltr" | "rtl"

The document's text/writing direction.

Type
"ltr" | "rtl"
Default
"ltr"
finalFocusEl?() → MaybeElement

Element to receive focus when the dialog is closed.

Returns
MaybeElement
hideMode?"display-none" | "activity"

How to hide content when mounted but not present. - display-none: HTML hidden attribute. Effects stay alive. - activity: React 19 <Activity mode="hidden">. Effects pause. Requires React 19+.

Type
"display-none" | "activity"
Default
"display-none"
id?string

The unique identifier of the machine.

ids?object

The ids of the elements in the dialog. Useful for composition.

Type
{ trigger?: string | ((value?: string) → string); positioner?: string; backdrop?: string; content?: string; closeTrigger?: string; title?: string; description?: string }
immediate?boolean

Whether to synchronize the present change immediately or defer it to the next frame.

initialFocusEl?() → MaybeElement | false

Element to receive focus when the dialog is opened. Return false to skip moving focus, or null to use the default.

Type
() → MaybeElement | false
Returns
MaybeElement | false
lazyMount?boolean

Whether to enable lazy mounting.

Default
false
modal?boolean

Whether to prevent pointer interaction outside the element and hide all content below it.

Default
true
onEnterComplete?VoidFunction

Function called when the animation ends in the open state.

onEscapeKeyDown?(event: KeyboardEvent) → void

Function called when the escape key is pressed.

Parameters

event – { altKey: boolean; charCode: number; ctrlKey: boolean; code: string; getModifierState: (key: string) → boolean; key: string; keyCode: number; locale: string; location: number; metaKey: boolean; repeat: boolean; shiftKey: boolean; which: number }

Returns
void
onExitComplete?VoidFunction

Function called when the animation ends in the closed state.

onFocusOutside?(event: FocusOutsideEvent) → void

Function called when the focus is moved outside the component.

Type
(event: FocusOutsideEvent) → void
Parameters

event – FocusOutsideEvent

Returns
void
onInteractOutside?(event: InteractOutsideEvent) → void

Function called when an interaction happens outside the component.

Type
(event: InteractOutsideEvent) → void
Parameters

event – InteractOutsideEvent

Returns
void
onPointerDownOutside?(event: PointerDownOutsideEvent) → void

Function called when the pointer is pressed down outside the component.

Type
(event: PointerDownOutsideEvent) → void
Parameters

event – PointerDownOutsideEvent

Returns
void
onRequestDismiss?(event: LayerDismissEvent) → void

Function called when this layer is closed due to a parent layer being closed.

Type
(event: LayerDismissEvent) → void
Parameters

event – LayerDismissEvent

Returns
void
persistentElements?Array<() → Element | null>

Returns the persistent elements that: - should not have pointer-events disabled - should not trigger the dismiss event

Type
Array<() → Element | null>
present?boolean

Whether the node is present (controlled by the user).

preventScroll?boolean

Whether to prevent scrolling behind the dialog when it's opened.

Default
true
restoreFocus?boolean

Whether to restore focus to the element that had focus before the dialog was opened.

role?"dialog" | "alertdialog"

The dialog's role.

Type
"dialog" | "alertdialog"
Default
"dialog"
skipAnimationOnMount?boolean

Whether to allow the initial presence animation.

Default
false
trapFocus?boolean

Whether to trap focus inside the dialog when it's opened.

Default
true
unmountOnExit?boolean

Whether to unmount on exit.

Default
false

SheetTrigger

<button> data-slot="sheet-trigger"

PropType
value?string

The value that identifies this specific trigger.

asChild?(props: ParentProps) => JSX.Element

Render your own element: a function that gets the part's props to spread on it.

Type
(props: ParentProps) => JSX.Element
AttributeType
data-current?string

Present when current.

data-state"open" | "closed"

"open" or "closed".

Type
"open" | "closed"
data-value?string

The value of the item.

SheetOverlay

<div> data-slot="sheet-overlay"

PropType
asChild?(props: ParentProps) => JSX.Element

Render your own element: a function that gets the part's props to spread on it.

Type
(props: ParentProps) => JSX.Element
class?string

Merged with the part's classes.

AttributeType
data-has-nested?string

Present when the backdrop has nested dialogs.

data-nested?string

Present when the backdrop is nested within another dialog.

data-state"open" | "closed"

"open" or "closed".

Type
"open" | "closed"
CSS variableType
--insetstring
--layer-indexstring

The index of the dismissable in the layer stack.

SheetPositioner

<div> data-slot="sheet-positioner"

PropType
placement?SheetSide

Deprecated. Prefer side. Kept for existing callers.

side?SheetSide

Edge of the screen where the sheet appears.

Default
right]:pt-(--inset) data-[side=right]:pb-(--inset)"
variant?"default" | "inset"

The visual style.

Type
"default" | "inset"
Default
"default"
asChild?(props: ParentProps) => JSX.Element

Render your own element: a function that gets the part's props to spread on it.

Type
(props: ParentProps) => JSX.Element
class?string

Merged with the part's classes.

AttributeType
data-has-nested?string

Present when the positioner has nested dialogs.

data-nested?string

Present when the positioner is nested within another dialog.

data-placement?string

Mirrors side.

data-side?string

Mirrors side.

data-variant?string

Mirrors variant.

SheetContent

<div> data-slot="sheet-content"

PropType
placement?SheetSide

Deprecated. Prefer side. Kept for Sidebar and other callers.

showCloseButton?boolean

Show close button at the top right corner.

Default
true
side?SheetSide

Edge of the screen where the sheet appears.

Default
"right"
asChild?(props: ParentProps) => JSX.Element

Render your own element: a function that gets the part's props to spread on it.

Type
(props: ParentProps) => JSX.Element
class?string

Merged with the part's classes.

AttributeType
data-has-nested?string

Present when another dialog is nested inside it.

data-nested?string

Present when it's nested inside another dialog.

data-side?string

Mirrors side.

data-state"open" | "closed"

"open" or "closed".

Type
"open" | "closed"
CSS variableType
--layer-indexstring

The index of the dismissable in the layer stack.

--nested-layer-countstring

The number of nested dialogs.

SheetTitle

<h2> data-slot="sheet-title"

PropType
asChild?(props: ParentProps) => JSX.Element

Render your own element: a function that gets the part's props to spread on it.

Type
(props: ParentProps) => JSX.Element
class?string

Merged with the part's classes.

SheetDescription

<div> data-slot="sheet-description"

PropType
asChild?(props: ParentProps) => JSX.Element

Render your own element: a function that gets the part's props to spread on it.

Type
(props: ParentProps) => JSX.Element
class?string

Merged with the part's classes.

SheetClose

<button> data-slot="sheet-close"

PropType
asChild?(props: ParentProps) => JSX.Element

Render your own element: a function that gets the part's props to spread on it.

Type
(props: ParentProps) => JSX.Element

SheetHeader

<div> data-slot="sheet-header"

PropType
description?string

The description of the sheet.

title?string

The title of the sheet.

class?string

Merged with the part's classes.

SheetBody

data-slot="sheet-body"

PropType
scrollFade?boolean

Add a fade effect to the scroll area.

Default
false
asChild?(props: ParentProps) => JSX.Element

Render your own element: a function that gets the part's props to spread on it.

Type
(props: ParentProps) => JSX.Element
class?string

Merged with the part's classes.

SheetFooter

data-slot="sheet-footer"

PropType
class?string

Merged with the part's classes.

useSheet