Caprice LogoCaprice UI

Sheet

Extends the Dialog component to display content that complements the main content of the screen.

Installation

npx shadcn@latest add @caprice/sheet

Usage

import * as Sheet from "@/components/caprice-ui/sheet"
<Sheet.Root>
  <Sheet.Trigger render={<Button>Open</Button>} />
  <Sheet.Popup>
    <Sheet.Header>
      <Sheet.Title>Edit Profile</Sheet.Title>
      <Sheet.Description>
        Make changes to your profile here. Click save when you're done.
      </Sheet.Description>
    </Sheet.Header>

    <Form className="grid flex-1 auto-rows-min gap-6 px-4">
      <Field.Root className="grid gap-3">
        <Field.Label htmlFor="sheet-demo-name">Name</Field.Label>
        <Input defaultValue="Sacha Osmani" id="sheet-demo-name" />
      </Field.Root>
      <Field.Root className="grid gap-3">
        <Field.Label htmlFor="sheet-demo-username">Username</Field.Label>
        <Input defaultValue="@sachaosmani" id="sheet-demo-username" />
      </Field.Root>
      <Button type="submit">Save</Button>
    </Form>

    <Sheet.Footer>
      <Sheet.Close render={<Button>Close</Button>} />
    </Sheet.Footer>
  </Sheet.Popup>
</Sheet.Root>

Examples

Side

Use the side property to <Sheet.Popup /> to indicate the edge of the screen where the component will appear. The values can be top, right, bottom or left.

Size

You can adjust the size of the sheet using CSS classes:

<Sheet.Root>
  <Sheet.Trigger>Open</Sheet.Trigger>
  <SheetContent className="w-[400px] sm:w-[540px]">
    <Sheet.Header>
      <Sheet.Title>Edit Profile</Sheet.Title>
      <Sheet.Description>
        Make changes to your profile here. Click save when you're done.
      </Sheet.Description>
    </Sheet.Header>
  </SheetContent>
</Sheet.Root>

Scrollable content