{
  "schemaVersion": 1,
  "target": "react",
  "name": "sheet",
  "version": "0.1.0",
  "category": "overlays",
  "title": "Sheet",
  "description": "A side panel that slides in from any edge of the screen for settings and detail views, built on Base UI Drawer so it traps focus like a dialog and can be swiped away on touch.",
  "tags": [
    "overlay",
    "panel",
    "side-panel",
    "drawer",
    "base-ui"
  ],
  "requires": {
    "projectTypes": [
      "next",
      "vite-react"
    ],
    "styling": "tailwind-v4"
  },
  "npmDependencies": {
    "@base-ui/react": "^1.9.0"
  },
  "registryDependencies": [
    {
      "name": "button",
      "version": "0.2.1"
    }
  ],
  "docsPath": "/components/sheet",
  "props": [
    {
      "name": "Sheet side",
      "type": "\"top\" | \"right\" | \"bottom\" | \"left\"",
      "default": "\"right\"",
      "description": "Edge the panel slides in from. Swiping toward that edge dismisses it."
    },
    {
      "name": "Sheet open / defaultOpen / onOpenChange",
      "type": "boolean / boolean / (open, details) => void",
      "description": "Root state. Leave open unset for an uncontrolled sheet."
    },
    {
      "name": "Sheet modal",
      "type": "boolean | \"trap-focus\"",
      "default": "true",
      "description": "Traps focus, locks page scroll, and blocks outside pointer interaction."
    },
    {
      "name": "SheetTrigger / SheetClose",
      "type": "Base UI Drawer.Trigger / Drawer.Close props",
      "description": "Unstyled buttons that open and close the sheet. Pass className, or render={<Button />}."
    },
    {
      "name": "SheetContent size",
      "type": "\"sm\" | \"md\" | \"lg\"",
      "default": "\"md\"",
      "description": "Width of a left or right sheet: 20rem, 24rem, or 32rem, capped at the screen width minus 3rem."
    },
    {
      "name": "SheetContent showCloseButton / closeLabel",
      "type": "boolean / string",
      "default": "true / \"Close\"",
      "description": "Corner icon button that closes the sheet, and its accessible name."
    },
    {
      "name": "SheetHeader / SheetBody / SheetFooter",
      "type": "div / Base UI Drawer.Content / div props",
      "description": "Layout: the header and footer stay fixed while the body scrolls. The footer is a band under a divider."
    },
    {
      "name": "SheetTitle / SheetDescription",
      "type": "Base UI Title / Description props",
      "description": "Heading and supporting text, wired to aria-labelledby and aria-describedby."
    }
  ],
  "accessibility": [
    "The panel has role=\"dialog\" and aria-modal, named by SheetTitle and described by SheetDescription.",
    "Opening moves focus into the sheet and traps Tab inside it; closing returns focus to the trigger.",
    "Escape and a click on the backdrop close the sheet; swiping is an extra way to dismiss, never the only one.",
    "The corner close button has an accessible name and a 32px target; its icon is hidden from screen readers.",
    "With reduced motion the slide and backdrop fade are removed; dragging still follows the finger because it is direct manipulation."
  ],
  "states": [
    "closed",
    "open",
    "swiping"
  ],
  "files": [
    {
      "path": "ui/sheet.tsx",
      "content": "\"use client\";\n\nimport { Drawer as BaseDrawer } from \"@base-ui/react/drawer\";\nimport { type ComponentProps, createContext, useContext } from \"react\";\n\ntype ClassName<State> = string | ((state: State) => string | undefined) | undefined;\n\nfunction cx(...classes: (string | false | null | undefined)[]) {\n  return classes.filter(Boolean).join(\" \");\n}\n\n/** Prepends base classes while keeping Base UI's state-function form of className working. */\nfunction withBase<State>(base: string, className: ClassName<State>) {\n  return typeof className === \"function\" ? (state: State) => cx(base, className(state)) : cx(base, className);\n}\n\nexport type SheetSide = \"top\" | \"right\" | \"bottom\" | \"left\";\n\nconst SideContext = createContext<SheetSide>(\"right\");\n\nconst swipeDirections = { top: \"up\", right: \"right\", bottom: \"down\", left: \"left\" } as const;\n\nexport interface SheetProps extends Omit<BaseDrawer.Root.Props, \"swipeDirection\" | \"snapPoints\" | \"snapPoint\" | \"defaultSnapPoint\" | \"onSnapPointChange\"> {\n  /** The screen edge the panel slides in from. A swipe or drag back toward that edge dismisses it. */\n  side?: SheetSide;\n}\n\n/**\n * Groups the sheet parts and holds its open state. Pass `open`/`onOpenChange` to control it.\n * Built on Base UI Drawer, so it traps focus like a dialog and can be swiped away on touch.\n */\nexport function Sheet({ side = \"right\", ...props }: SheetProps) {\n  return (\n    <SideContext.Provider value={side}>\n      <BaseDrawer.Root swipeDirection={swipeDirections[side]} {...props} />\n    </SideContext.Provider>\n  );\n}\n\n/** A button that opens the sheet. Unstyled; pass `className`, or `render={<Button />}` to reuse your button. */\nexport const SheetTrigger = BaseDrawer.Trigger;\n\n/** A button that closes the sheet. Unstyled; pass `className` or `render`. */\nexport const SheetClose = BaseDrawer.Close;\n\nconst sizes = {\n  sm: \"[--sheet-size:20rem]\",\n  md: \"[--sheet-size:24rem]\",\n  lg: \"[--sheet-size:32rem]\",\n} as const;\n\nexport type SheetSize = keyof typeof sizes;\n\n// Where the viewport parks the panel, the hairline on its inner edge, and the off-screen position it\n// enters from and leaves to. Swipe movement is added to the resting translate while dragging.\nconst placement = {\n  right: {\n    viewport: \"justify-end\",\n    popup: cx(\n      \"h-full w-[min(var(--sheet-size),calc(100vw-3rem))] border-l\",\n      \"translate-x-[var(--drawer-swipe-movement-x,0px)] data-[starting-style]:translate-x-full data-[ending-style]:translate-x-full\",\n    ),\n  },\n  left: {\n    viewport: \"justify-start\",\n    popup: cx(\n      \"h-full w-[min(var(--sheet-size),calc(100vw-3rem))] border-r\",\n      \"translate-x-[var(--drawer-swipe-movement-x,0px)] data-[starting-style]:-translate-x-full data-[ending-style]:-translate-x-full\",\n    ),\n  },\n  top: {\n    viewport: \"flex-col justify-start\",\n    popup: cx(\n      \"max-h-[calc(100dvh-3rem)] w-full border-b\",\n      \"translate-y-[var(--drawer-swipe-movement-y,0px)] data-[starting-style]:-translate-y-full data-[ending-style]:-translate-y-full\",\n    ),\n  },\n  bottom: {\n    viewport: \"flex-col justify-end\",\n    popup: cx(\n      \"max-h-[calc(100dvh-3rem)] w-full border-t pb-[env(safe-area-inset-bottom,0px)]\",\n      \"translate-y-[var(--drawer-swipe-movement-y,0px)] data-[starting-style]:translate-y-full data-[ending-style]:translate-y-full\",\n    ),\n  },\n} as const;\n\nexport interface SheetContentProps extends BaseDrawer.Popup.Props {\n  /** Width of a left or right sheet: 20rem, 24rem, or 32rem, never wider than the screen minus 3rem. */\n  size?: SheetSize;\n  /** Renders an icon button in the corner that closes the sheet. */\n  showCloseButton?: boolean;\n  /** Accessible name of the corner close button. */\n  closeLabel?: string;\n  /** Classes for the backdrop behind the panel. */\n  backdropClassName?: string;\n  /** Element to portal into. Defaults to `document.body`. */\n  container?: BaseDrawer.Portal.Props[\"container\"];\n}\n\n/**\n * The sliding panel, rendered in a portal above a backdrop. Lay it out with SheetHeader, SheetBody,\n * and SheetFooter: the header and footer stay put while the body scrolls.\n */\nexport function SheetContent({\n  size = \"md\",\n  showCloseButton = true,\n  closeLabel = \"Close\",\n  backdropClassName,\n  container,\n  className,\n  children,\n  ...props\n}: SheetContentProps) {\n  const side = useContext(SideContext);\n\n  return (\n    <BaseDrawer.Portal container={container}>\n      <BaseDrawer.Backdrop\n        className={cx(\n          \"fixed inset-0 z-50 bg-black/40 dark:bg-black/70\",\n          // Fades with the swipe so the page shows through as the panel is dragged away.\n          \"opacity-[calc(1-var(--drawer-swipe-progress,0))]\",\n          \"transition-opacity duration-300 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none\",\n          \"data-[starting-style]:opacity-0 data-[ending-style]:opacity-0 data-[ending-style]:duration-[calc(var(--drawer-swipe-strength,1)*200ms)] data-[swiping]:duration-0\",\n          backdropClassName,\n        )}\n      />\n      <BaseDrawer.Viewport className={cx(\"fixed inset-0 z-50 flex\", placement[side].viewport)}>\n        <BaseDrawer.Popup\n          data-side={side}\n          className={withBase(\n            cx(\n              \"relative flex flex-col overflow-hidden overscroll-contain outline-none\",\n              \"border-zinc-950/10 bg-white text-zinc-950 shadow-[0_0_48px_-12px_rgb(0_0_0/0.24)]\",\n              \"dark:border-white/15 dark:bg-black dark:text-white dark:shadow-[0_0_64px_-8px_rgb(0_0_0/1)]\",\n              \"focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-sky-500\",\n              // Enter: 300ms quint ease-out from the edge. Exit: 200ms, shorter still after a fast swipe.\n              \"transition-[translate] duration-300 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none\",\n              \"data-[ending-style]:duration-[calc(var(--drawer-swipe-strength,1)*200ms)] data-[ending-style]:ease-[cubic-bezier(0.32,0.72,0,1)]\",\n              \"data-[swiping]:duration-0 data-[swiping]:select-none\",\n              placement[side].popup,\n              sizes[size],\n            ),\n            className,\n          )}\n          {...props}\n        >\n          {children}\n          {showCloseButton ? (\n            <BaseDrawer.Close\n              aria-label={closeLabel}\n              className={cx(\n                \"absolute top-4 right-4 inline-flex size-8 items-center justify-center rounded-lg text-zinc-500\",\n                \"transition-[background-color,color,scale] duration-150 ease-out active:duration-100 motion-reduce:transition-none\",\n                \"hover:bg-zinc-950/[0.05] hover:text-zinc-950 motion-safe:active:scale-[0.94]\",\n                \"dark:hover:bg-white/[0.08] dark:hover:text-white\",\n                \"focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-sky-500\",\n              )}\n            >\n              <svg aria-hidden=\"true\" viewBox=\"0 0 16 16\" fill=\"none\" className=\"size-4\">\n                <path d=\"M4.5 4.5l7 7M11.5 4.5l-7 7\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" />\n              </svg>\n            </BaseDrawer.Close>\n          ) : null}\n        </BaseDrawer.Popup>\n      </BaseDrawer.Viewport>\n    </BaseDrawer.Portal>\n  );\n}\n\n// Top and bottom sheets span the window; keep their content in a readable 48rem column.\nconst wideGutter =\n  \"in-data-[side=top]:px-[max(1.5rem,calc((100%-48rem)/2))] in-data-[side=bottom]:px-[max(1.5rem,calc((100%-48rem)/2))]\";\n\n/** Wraps the title and description at the top of the panel. Leaves room for the close button. */\nexport function SheetHeader({ className, ...props }: ComponentProps<\"div\">) {\n  return <div className={cx(\"grid shrink-0 gap-1.5 px-6 pt-6 pb-4 pr-14\", wideGutter, className)} {...props} />;\n}\n\n/**\n * The scrolling middle of the panel. Text in it can be selected with a mouse without starting a\n * swipe. Mark a horizontal scroller inside it with `data-base-ui-swipe-ignore` to keep its drags.\n */\nexport function SheetBody({ className, ...props }: BaseDrawer.Content.Props) {\n  return (\n    <BaseDrawer.Content\n      className={withBase(cx(\"min-h-0 flex-1 overflow-y-auto overscroll-contain px-6 pb-6 text-sm\", wideGutter), className)}\n      {...props}\n    />\n  );\n}\n\n/** Holds the actions in a band under a divider at the bottom of the panel. */\nexport function SheetFooter({ className, ...props }: ComponentProps<\"div\">) {\n  return (\n    <div\n      className={cx(\n        \"mt-auto flex shrink-0 flex-col-reverse gap-2 border-t border-zinc-950/[0.07] bg-zinc-950/[0.015] px-6 py-4 sm:flex-row sm:justify-end\",\n        \"dark:border-white/[0.08] dark:bg-transparent\",\n        wideGutter,\n        className,\n      )}\n      {...props}\n    />\n  );\n}\n\n/** The sheet's heading. Labels the panel with aria-labelledby. */\nexport function SheetTitle({ className, ...props }: BaseDrawer.Title.Props) {\n  return <BaseDrawer.Title className={withBase(\"text-base leading-6 font-semibold tracking-[-0.01em]\", className)} {...props} />;\n}\n\n/** Supporting text. Describes the panel with aria-describedby. */\nexport function SheetDescription({ className, ...props }: BaseDrawer.Description.Props) {\n  return (\n    <BaseDrawer.Description className={withBase(\"text-sm leading-relaxed text-zinc-600 dark:text-zinc-400\", className)} {...props} />\n  );\n}\n"
    }
  ],
  "example": {
    "content": "\"use client\";\n\nimport { useState } from \"react\";\nimport { Button } from \"@/components/shaken/ui/button\";\nimport {\n  Sheet,\n  SheetBody,\n  SheetClose,\n  SheetContent,\n  SheetDescription,\n  SheetFooter,\n  SheetHeader,\n  type SheetSide,\n  SheetTitle,\n} from \"@/components/shaken/ui/sheet\";\n\nconst sides: SheetSide[] = [\"left\", \"top\", \"bottom\", \"right\"];\n\nconst rules = [\n  { id: \"deploys\", label: \"Production deploys\", detail: \"Ask before the agent deploys to production.\", on: true },\n  { id: \"secrets\", label: \"Secrets and keys\", detail: \"Ask before reading or rotating environment secrets.\", on: true },\n  { id: \"migrations\", label: \"Database migrations\", detail: \"Ask before running a migration against any database.\", on: true },\n  { id: \"deps\", label: \"New dependencies\", detail: \"Ask before adding a package to package.json.\", on: false },\n];\n\nexport default function SheetExample() {\n  const [side, setSide] = useState<SheetSide>(\"right\");\n  const [open, setOpen] = useState(false);\n\n  return (\n    <div className=\"flex flex-wrap items-center justify-center gap-2\">\n      {sides.map((edge) => (\n        <Button\n          key={edge}\n          variant=\"secondary\"\n          onClick={() => {\n            setSide(edge);\n            setOpen(true);\n          }}\n        >\n          Open {edge}\n        </Button>\n      ))}\n\n      <Sheet side={side} open={open} onOpenChange={setOpen}>\n        <SheetContent>\n          <SheetHeader>\n            <SheetTitle>Approval rules</SheetTitle>\n            <SheetDescription>Choose which actions pause the agent until someone on your team approves them.</SheetDescription>\n          </SheetHeader>\n          <SheetBody>\n            <ul className=\"divide-y divide-zinc-950/[0.07] rounded-lg border border-zinc-950/[0.07] dark:divide-white/[0.08] dark:border-white/[0.08]\">\n              {rules.map((rule) => (\n                <li key={rule.id}>\n                  <label className=\"flex cursor-pointer items-start gap-3 px-3 py-3\">\n                    <input\n                      type=\"checkbox\"\n                      defaultChecked={rule.on}\n                      className=\"mt-0.5 size-4 shrink-0 accent-zinc-950 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-sky-500 dark:accent-white\"\n                    />\n                    <span className=\"grid gap-0.5\">\n                      <span className=\"font-medium\">{rule.label}</span>\n                      <span className=\"text-zinc-600 dark:text-zinc-400\">{rule.detail}</span>\n                    </span>\n                  </label>\n                </li>\n              ))}\n            </ul>\n            <p className=\"mt-4 text-xs text-zinc-500\">Changes apply to runs that start after you save.</p>\n          </SheetBody>\n          <SheetFooter>\n            <SheetClose render={<Button variant=\"secondary\" />}>Cancel</SheetClose>\n            <SheetClose render={<Button />}>Save rules</SheetClose>\n          </SheetFooter>\n        </SheetContent>\n      </Sheet>\n    </div>\n  );\n}\n"
  }
}
