Early bird: 30% off Dashral ProSee pricing

Dashral

Sheet

Sheet with motion: it slides in on a smooth curve while what's inside follows a moment later, and on a touch screen you drag it back toward its edge to close it.

$ pnpm dlx shadcn@latest add @dashral/motion-sheet

Installation

$ pnpm dlx shadcn@latest add @dashral/motion-sheet

Adds components/dashral/motion/sheet.tsx, the Sheet it builds on (in components/dashral/), motion and the motion files every motion component shares. Or by its full URL: https://dashral.com/r/motion-sheet.json

Usage

The same as Sheet, imported from components/dashral/motion/ (with the npm package: @dashral/motion/components/sheet): swap the import and it moves.

example.tsx
import { Sheet, SheetClose } from "@/components/dashral/motion/sheet"

<Sheet
  trigger={<Button variant="outline">Filters</Button>}
  title="Filters"
  footer={<SheetClose asChild><Button>Show results</Button></SheetClose>}
>
  <FilterForm />
</Sheet>

Examples

A phone's menu

side="start" and padding="none": on a phone, drag it back toward its edge to close it, or pick a page.

Overview

On a phone, or in your browser's device mode, drag the menu back toward its edge to close it.

Bottom sheet

side="bottom" with a handle on touch screens: drag it down and it follows your finger as the backdrop clears.

On a phone, or in your browser's device mode, drag the sheet down to close it.

Compared with Default

Default

Slides in from its edge with CSS, and closes with the button, Escape or a click outside.

Motion

Slides in on a smooth curve with its content following a moment later; on a touch screen, drag it back toward its edge and it follows your finger.

How the two editions differ in general, and which to use where: Motion.

API reference

Every prop of Sheet, and every attribute of the element it renders. What the Motion edition adds is marked Motion.

Sheet

Also takes every prop of Radix Dialog(opens in a new tab).

PropTypeDefault
swipeToCloseboolean

Motion On a touch screen, drag the panel back toward its edge to close it.

true
triggerReactElement

What opens it. Leave it out to open it with open / onOpenChange.

—
titleReactNode

Required: it names the panel.

—
descriptionReactNode—
childrenReactNode

The body; it scrolls when it's taller than the screen.

—
footerReactNode

Pinned to the bottom.

—
formComponentProps<"form">

Makes the body and footer one form.

—
side"top" | "bottom" | "start" | "end" | "left" | "right"

Which edge it slides from. start and end follow the reading direction (end is the right, or the left in Arabic).

"end"
padding"default" | "none"

none hides the header visually and drops the body's padding, for a layout of your own.

"default"
showCloseButtonbooleantrue
autoFocusboolean

Opening it focuses the first control inside. false focuses the panel instead, e.g. a menu whose first control is a text field, so a phone doesn't open its keyboard.

true
classNames{ header, title, description, body, footer }

Classes for each part.

—
classNamestring

The panel's classes, e.g. a width.

—

SheetClose

Closes the sheet: wrap a button.

Also takes every prop of Radix Dialog(opens in a new tab).

PropTypeDefault
asChildboolean

Render the child element instead (e.g. a Next.js Link), passing these styles and props to it.

false

SheetClose is the default edition's, re-exported, so a footer works the same with either.

Motion

  • It slides in from its edge in 0.45s on a smooth curve (no spring, no overshoot) while the backdrop fades in; the header, body and footer follow 0.12s later, each a little after the one before, rising a few pixels from the edge.
  • Closing, it slides back out in 0.3s (--ease-exit) as the backdrop clears; the backdrop's blur stays put and only fades, so it never costs frames.
  • On a touch screen, a drag toward its edge (not in a field) moves it 1:1 with your finger while the backdrop clears; past a third of its size, or flicked, it slides away closed and the phone buzzes; short of it it glides back in 0.3s. The other way it barely gives. A side sheet tells a drag from a scroll by the first few pixels, so its body still scrolls; a bottom sheet's tall body keeps the finger for scrolling.
  • start and end follow the reading direction, the drag included. With reduced motion it only fades, and doesn't drag.