{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "toast",
  "title": "Toast",
  "description": "Edge toast stack on Base UI with opacity+y enter/exit and careful CSS-var stacking.",
  "dependencies": [
    "@base-ui/react",
    "lucide-react",
    "motion"
  ],
  "registryDependencies": [
    "@atroui/utils",
    "@atroui/motion",
    "@atroui/button"
  ],
  "files": [
    {
      "path": "registry/default/ui/toast.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { Toast as ToastPrimitive } from \"@base-ui/react/toast\"\nimport { X } from \"lucide-react\"\nimport { motion, useReducedMotion } from \"motion/react\"\n\nimport { toastMotion, toastTween, exitTween, enterTween } from \"@/lib/motion\"\nimport { cn } from \"@/lib/utils\"\nimport { Button } from \"./button\"\n\n/** Layered pop elevation — ring-as-border + cast stack + top light. */\nconst toastElevation =\n  \"ds-elev-pop\"\n\nfunction ToastProvider({ ...props }: ToastPrimitive.Provider.Props) {\n  return <ToastPrimitive.Provider data-slot=\"toast-provider\" {...props} />\n}\n\nfunction ToastPortal({ ...props }: ToastPrimitive.Portal.Props) {\n  return <ToastPrimitive.Portal data-slot=\"toast-portal\" {...props} />\n}\n\nfunction ToastViewport({\n  className,\n  ...props\n}: ToastPrimitive.Viewport.Props) {\n  return (\n    <ToastPrimitive.Viewport\n      data-slot=\"toast-viewport\"\n      className={cn(\n        \"fixed right-4 bottom-4 z-50 flex w-[calc(100%-2rem)] max-w-sm flex-col outline-none sm:right-6 sm:bottom-6\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\n/**\n * Soft-rect toast — edge enter/exit opacity + y (`toastTween`).\n *\n * Stack carefully: Root owns CSS-var stack (`--toast-index`, `--toast-offset-y`)\n * without Motion `y` on the same node. An inner surface runs opacity+y so enter\n * travel does not fight the stack transform. Root still animates opacity so\n * Base UI `getAnimations()` can await leave.\n */\nfunction Toast({\n  className,\n  toast,\n  children,\n  ...props\n}: ToastPrimitive.Root.Props) {\n  const reduce = useReducedMotion()\n  const ending = toast.transitionStatus === \"ending\"\n\n  return (\n    <ToastPrimitive.Root\n      data-slot=\"toast\"\n      toast={toast}\n      className={cn(\n        \"pointer-events-auto absolute right-0 bottom-0 z-[calc(1000-var(--toast-index))] w-full origin-bottom-right\",\n        /* Stack: CSS vars only — do not put Motion y on this node */\n        \"[transform:translateX(var(--toast-swipe-movement-x,0px))_translateY(calc(var(--toast-swipe-movement-y,0px)+var(--toast-offset-y,0px)-var(--toast-index)*12px))_scale(calc(1-var(--toast-index)*0.04))]\",\n        \"data-expanded:[transform:translateX(var(--toast-swipe-movement-x,0px))_translateY(calc(var(--toast-swipe-movement-y,0px)+var(--toast-offset-y,0px)))_scale(1)]\",\n        \"data-limited:pointer-events-none data-limited:opacity-0\",\n        \"transition-[transform] duration-200 ease-[cubic-bezier(0.32,0.72,0,1)] motion-reduce:transition-none\",\n        className\n      )}\n      render={\n        <motion.div\n          initial={false}\n          animate={{ opacity: ending || toast.limited ? 0 : 1 }}\n          transition={\n            reduce\n              ? { duration: 0 }\n              : ending || toast.limited\n                ? exitTween(toastTween.duration, toastTween.ease)\n                : enterTween(toastTween.duration, toastTween.ease)\n          }\n        />\n      }\n      {...props}\n    >\n      <motion.div\n        className={cn(\n          \"rounded-[var(--radius)] bg-popover text-popover-foreground outline-none\",\n          toastElevation\n        )}\n        {...toastMotion(reduce, ending)}\n      >\n        {children}\n      </motion.div>\n    </ToastPrimitive.Root>\n  )\n}\n\nfunction ToastContent({\n  className,\n  ...props\n}: ToastPrimitive.Content.Props) {\n  return (\n    <ToastPrimitive.Content\n      data-slot=\"toast-content\"\n      className={cn(\n        \"flex flex-col gap-0.5 overflow-hidden p-3 pr-9\",\n        \"data-behind:opacity-0 data-expanded:data-behind:opacity-100\",\n        \"transition-opacity duration-200 motion-reduce:transition-none\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\nfunction ToastTitle({ className, ...props }: ToastPrimitive.Title.Props) {\n  return (\n    <ToastPrimitive.Title\n      data-slot=\"toast-title\"\n      className={cn(\n        \"text-[0.875rem] font-medium leading-snug tracking-tight\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\nfunction ToastDescription({\n  className,\n  ...props\n}: ToastPrimitive.Description.Props) {\n  return (\n    <ToastPrimitive.Description\n      data-slot=\"toast-description\"\n      className={cn(\"text-sm leading-relaxed text-muted-foreground\", className)}\n      {...props}\n    />\n  )\n}\n\nfunction ToastAction({ className, ...props }: ToastPrimitive.Action.Props) {\n  return (\n    <ToastPrimitive.Action\n      data-slot=\"toast-action\"\n      className={cn(\"mt-2 self-start\", className)}\n      {...props}\n    />\n  )\n}\n\nfunction ToastClose({\n  className,\n  render,\n  ...props\n}: ToastPrimitive.Close.Props) {\n  return (\n    <ToastPrimitive.Close\n      data-slot=\"toast-close\"\n      className={cn(className)}\n      render={\n        render ?? (\n          <Button\n            variant=\"ghost\"\n            size=\"icon-sm\"\n            className=\"absolute top-2.5 right-2.5 text-muted-foreground hover:text-foreground\"\n          />\n        )\n      }\n      {...props}\n    >\n      <X className=\"size-3.5\" strokeWidth={1.75} />\n      <span className=\"sr-only\">Close</span>\n    </ToastPrimitive.Close>\n  )\n}\n\n/**\n * Opinionated stack renderer — maps `useToastManager().toasts`.\n * Place once under `ToastProvider` (usually near app root / demo stage).\n */\nfunction Toaster({ className }: { className?: string }) {\n  const { toasts } = ToastPrimitive.useToastManager()\n\n  return (\n    <ToastPortal>\n      <ToastViewport className={className}>\n        {toasts.map((toast) => (\n          <Toast key={toast.id} toast={toast}>\n            <ToastContent>\n              {toast.title ? <ToastTitle>{toast.title}</ToastTitle> : null}\n              {toast.description ? (\n                <ToastDescription>{toast.description}</ToastDescription>\n              ) : null}\n              {toast.actionProps ? (\n                <ToastAction {...toast.actionProps} />\n              ) : null}\n            </ToastContent>\n            <ToastClose />\n          </Toast>\n        ))}\n      </ToastViewport>\n    </ToastPortal>\n  )\n}\n\nconst useToastManager = ToastPrimitive.useToastManager\nconst createToastManager = ToastPrimitive.createToastManager\n\nexport {\n  Toast,\n  ToastAction,\n  ToastClose,\n  ToastContent,\n  ToastDescription,\n  Toaster,\n  ToastPortal,\n  ToastProvider,\n  ToastTitle,\n  ToastViewport,\n  createToastManager,\n  useToastManager,\n}\n",
      "type": "registry:ui",
      "target": "components/ui/toast.tsx"
    }
  ],
  "type": "registry:ui"
}