Skip to main content

Starwind UI v3.0 is now available! Migration guide

Edit Profile

Make changes to your profile here. Click save when you’re done.

Installation

Usage

---
import { Button } from "@/components/starwind/button";
import { Input } from "@/components/starwind/input";
import { Label } from "@/components/starwind/label";
import {
Sheet,
SheetClose,
SheetContent,
SheetDescription,
SheetFooter,
SheetHeader,
SheetTitle,
SheetTrigger,
} from "@/components/starwind/sheet";
---
<Sheet>
<SheetTrigger asChild>
<Button>Open Sheet</Button>
</SheetTrigger>
<SheetContent>
<SheetHeader>
<SheetTitle>Edit Profile</SheetTitle>
<SheetDescription>
Make changes to your profile here. Click save when you're done.
</SheetDescription>
</SheetHeader>
<div class="grid gap-4 px-4">
<div class="grid gap-2">
<Label for="name">Name</Label>
<Input id="name" value="Pedro Duarte" />
</div>
<div class="grid gap-2">
<Label for="username">Username</Label>
<Input id="username" value="@peduarte" />
</div>
</div>
<SheetFooter>
<SheetClose asChild>
<Button type="submit">Save changes</Button>
</SheetClose>
</SheetFooter>
</SheetContent>
</Sheet>

Composition

Use this structure for a sheet:

Sheet
├── SheetTrigger
└── SheetContent
├── SheetHeader
│ ├── SheetTitle
│ └── SheetDescription
└── SheetFooter

SheetContent includes a close button. Use SheetClose when another control also needs to close the sheet.

When to Use

Use Sheet for supporting content that slides in from an edge, such as a form or mobile navigation.

Side

Sheets can slide out from any side of the screen using the side prop.

Top Sheet

This sheet opens from the top of the screen.

Right Sheet

This sheet opens from the right side of the screen.

Bottom Sheet

This sheet opens from the bottom of the screen.

Left Sheet

This sheet opens from the left side of the screen.

API Reference

Styled Component API

These props are added or materially changed by the installed styled component. Standard HTML attributes remain available through the inherited interfaces noted below. Expand a prop to see named type definitions and framework-specific imports. Follow the Primitive and Runtime links for lower-level behavior props.

Sheet Trigger

Inherits button attributes.

Contains the following additional props:

Prop Type Default Toggle details
asChild boolean false
Description
Merges the component behavior and props into its child element.
Classification
Primitive override
Primitive prop
drawer.Trigger.asChild

Sheet Close

Inherits button attributes.

Contains the following additional props:

Prop Type Default Toggle details
asChild boolean false
Description
Merges the component behavior and props into its child element.
Classification
Primitive override
Primitive prop
drawer.Close.asChild

Primitive And Runtime API

Use these references when you need the lower-level behavior APIs behind Sheet.

Primitive API

Runtime API

Drawer primitive
createDrawer from @starwind-ui/runtime/drawer

Changelog

View version history v2.1.0 4 releases

v2.1.0

  • In Astro, SheetTrigger and SheetClose with asChild now make your own element a working control. Before, a button child gave a control that did nothing.
  • In Astro, an attribute that you set on SheetHeader and SheetFooter now wins over the component’s own default for the same attribute, such as role or aria-label.
  • In Svelte, a defined open that you pass when Sheet mounts now stays under your control, as in React and Vue. To change it, use bind: or update your state in the change callback. A form reset keeps it. If you pass undefined at mount, Sheet keeps its own state.

v2.0.3

  • Vue Drawer keeps its current open state when a change is canceled and responds to later open or close requests from your app.
  • Trigger and close buttons added after the drawer mounts now work without reopening it.
  • Reduced background work when a React page uses multiple menus, tooltips, or other portals.
  • Fixed React 18 retaining removed popup elements when the parent component stays mounted.

v2.0.2

  • The default export in index.ts now has a name, SheetParts, so framework tools show a clear name.

v2.0.0

  • Sheet now gets its behavior from the Drawer in Starwind Runtime. Its styled props stay the same.
  • See the Drawer Primitive for the unstyled parts and the behavior API.