{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"sonner","title":"Sonner","description":"Toast notifications on Sonner that follow Ward's light and dark theme, with Toaster and toast imported from one place.","dependencies":["sonner@2.0.8"],"registryDependencies":[],"files":[{"path":"registry/ward/ui/sonner.tsx","content":"\"use client\"\n\n/*\n * Adapted from shadcn/ui (https://github.com/shadcn-ui/ui).\n *\n * MIT License\n *\n * Copyright (c) 2023 shadcn\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport * as React from \"react\"\nimport { Toaster as Sonner, type ToasterProps } from \"sonner\"\n\n// Apps import toast from here too, so the Toaster and every toast() call share one sonner instance.\nexport { toast } from \"sonner\"\n\n// Ward sets data-theme on <html>; shadcn projects toggle the .dark class. Read either instead of next-themes.\nfunction useDocumentTheme(): ToasterProps[\"theme\"] {\n  const [theme, setTheme] = React.useState<ToasterProps[\"theme\"]>(\"light\")\n\n  React.useEffect(() => {\n    const root = document.documentElement\n    const read = () =>\n      setTheme(\n        root.dataset.theme === \"dark\" || root.classList.contains(\"dark\")\n          ? \"dark\"\n          : \"light\"\n      )\n    read()\n    const observer = new MutationObserver(read)\n    observer.observe(root, {\n      attributes: true,\n      attributeFilter: [\"class\", \"data-theme\"],\n    })\n    return () => observer.disconnect()\n  }, [])\n\n  return theme\n}\n\nconst Toaster = ({ ...props }: ToasterProps) => {\n  const theme = useDocumentTheme()\n\n  return (\n    <Sonner\n      theme={theme}\n      className=\"toaster group\"\n      style={\n        {\n          \"--normal-bg\": \"var(--popover)\",\n          \"--normal-text\": \"var(--popover-foreground)\",\n          \"--normal-border\": \"var(--border)\",\n        } as React.CSSProperties\n      }\n      {...props}\n    />\n  )\n}\n\nexport { Toaster }\n","type":"registry:ui"}],"meta":{"variants":["Default"],"version":"1.0.0","source":"https://github.com/shadcn-ui/ui/blob/main/apps/v4/registry/new-york-v4/ui/sonner.tsx","access":"free"},"categories":["primitives"],"type":"registry:ui"}