{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "toggles-3d",
  "title": "3D toggles",
  "description": "Styled toggles: the 3D set. 5 decorative toggles variations (RaisedToggle, PillPressToggle, TactileToggle, DomeToggle, SwitchLeverToggle) on the ai2 token system, powered by framer-motion, reduced-motion aware and sized sm to xl. Part of the free styled layer.",
  "dependencies": [
    "motion@^12.42.2"
  ],
  "registryDependencies": [
    "@ai2/tokens"
  ],
  "files": [
    {
      "path": "registry/ai2/styled/toggles-3d.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { motion, useReducedMotion } from \"motion/react\"\n\nimport { cn } from \"@/lib/utils\"\n\n/* 3D toggle family: 5 depth switches. role=\"switch\", keyboard accessible. Color\n   comes ONLY from tokens; the shadow/highlight uses token color-mix. The thumb\n   slides with the framer-motion `layout`, and switches instantly under\n   reduced-motion. Uncontrolled/controlled. */\n\nexport type StyledSize = \"sm\" | \"md\" | \"lg\" | \"xl\"\n\nconst trackSize: Record<StyledSize, string> = {\n  sm: \"h-5 w-9 p-0.5\",\n  md: \"h-6 w-11 p-0.5\",\n  lg: \"h-7 w-[52px] p-1\",\n  xl: \"h-8 w-[60px] p-1\",\n}\nconst thumbSize: Record<StyledSize, string> = {\n  sm: \"size-4\",\n  md: \"size-5\",\n  lg: \"size-5\",\n  xl: \"size-6\",\n}\n\nconst trackBase =\n  \"relative inline-flex shrink-0 cursor-pointer items-center outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50\"\n\ninterface ToggleProps extends Omit<React.ComponentProps<\"button\">, \"onChange\"> {\n  size?: StyledSize\n  checked?: boolean\n  defaultChecked?: boolean\n  onCheckedChange?: (checked: boolean) => void\n}\n\nfunction useToggle(props: ToggleProps) {\n  const { checked, defaultChecked, onCheckedChange } = props\n  const reduce = useReducedMotion()\n  const [internal, setInternal] = React.useState(defaultChecked ?? false)\n  const on = checked ?? internal\n  const toggle = () => {\n    if (checked === undefined) setInternal((v) => !v)\n    onCheckedChange?.(!on)\n  }\n  const spring = reduce ? { duration: 0 } : ({ type: \"spring\", stiffness: 500, damping: 30 } as const)\n  return { on, toggle, spring }\n}\n\nfunction stripToggleProps(props: ToggleProps) {\n  const { checked, defaultChecked, onCheckedChange, size, className, children, ...rest } = props\n  return rest\n}\n\n/* Raised: 3D kabartma govdeli basparmak, token alt golge. */\nexport function RaisedToggle(props: ToggleProps) {\n  const { on, toggle, spring } = useToggle(props)\n  const size = props.size ?? \"md\"\n  return (\n    <button\n      type=\"button\"\n      role=\"switch\"\n      aria-checked={on}\n      data-slot=\"styled-toggle\"\n      onClick={toggle}\n      className={cn(trackBase, trackSize[size], \"rounded-full transition-colors\", on ? \"justify-end bg-primary\" : \"justify-start bg-input\", props.className)}\n      {...stripToggleProps(props)}\n    >\n      <motion.span\n        layout\n        transition={spring}\n        className={cn(thumbSize[size], \"rounded-full bg-background\")}\n        style={{ boxShadow: \"0 2px 3px 0 color-mix(in oklab, var(--foreground) 30%, transparent), inset 0 1px 0 0 color-mix(in oklab, var(--background) 90%, transparent)\" }}\n      />\n    </button>\n  )\n}\n\n/* PillPress: iz basik/oyuk gorunur (inset golge). */\nexport function PillPressToggle(props: ToggleProps) {\n  const { on, toggle, spring } = useToggle(props)\n  const size = props.size ?? \"md\"\n  return (\n    <button\n      type=\"button\"\n      role=\"switch\"\n      aria-checked={on}\n      data-slot=\"styled-toggle\"\n      onClick={toggle}\n      className={cn(trackBase, trackSize[size], \"rounded-full transition-colors\", on ? \"justify-end bg-success\" : \"justify-start bg-input\", props.className)}\n      style={{ boxShadow: \"inset 0 2px 4px 0 color-mix(in oklab, var(--foreground) 28%, transparent)\" }}\n      {...stripToggleProps(props)}\n    >\n      <motion.span\n        layout\n        transition={spring}\n        className={cn(thumbSize[size], \"rounded-full bg-background\")}\n        style={{ boxShadow: \"0 1px 2px 0 color-mix(in oklab, var(--foreground) 25%, transparent)\" }}\n      />\n    </button>\n  )\n}\n\n/* Tactile: tiklandiginda basparmak asagi bastirilir (y ofset). */\nexport function TactileToggle(props: ToggleProps) {\n  const { on, toggle, spring } = useToggle(props)\n  const reduce = useReducedMotion()\n  const size = props.size ?? \"md\"\n  return (\n    <button\n      type=\"button\"\n      role=\"switch\"\n      aria-checked={on}\n      data-slot=\"styled-toggle\"\n      onClick={toggle}\n      className={cn(trackBase, trackSize[size], \"rounded-full transition-colors\", on ? \"justify-end bg-info\" : \"justify-start bg-input\", props.className)}\n      {...stripToggleProps(props)}\n    >\n      <motion.span\n        layout\n        transition={spring}\n        whileTap={reduce ? undefined : { y: 1, scale: 0.92 }}\n        className={cn(thumbSize[size], \"rounded-full bg-background\")}\n        style={{ boxShadow: \"0 2px 3px 0 color-mix(in oklab, var(--foreground) 30%, transparent)\" }}\n      />\n    </button>\n  )\n}\n\n/* Dome: kubbeli basparmak, ust highlight parlamasi. */\nexport function DomeToggle(props: ToggleProps) {\n  const { on, toggle, spring } = useToggle(props)\n  const size = props.size ?? \"md\"\n  return (\n    <button\n      type=\"button\"\n      role=\"switch\"\n      aria-checked={on}\n      data-slot=\"styled-toggle\"\n      onClick={toggle}\n      className={cn(trackBase, trackSize[size], \"rounded-full transition-colors\", on ? \"justify-end bg-primary\" : \"justify-start bg-input\", props.className)}\n      {...stripToggleProps(props)}\n    >\n      <motion.span\n        layout\n        transition={spring}\n        className={cn(thumbSize[size], \"relative overflow-hidden rounded-full bg-background\")}\n        style={{ boxShadow: \"0 2px 4px 0 color-mix(in oklab, var(--foreground) 32%, transparent)\" }}\n      >\n        <span\n          aria-hidden\n          className=\"absolute inset-x-1 top-0.5 h-1/3 rounded-full\"\n          style={{ background: \"color-mix(in oklab, var(--background) 85%, transparent)\" }}\n        />\n      </motion.span>\n    </button>\n  )\n}\n\n/* SwitchLever: kol/rocker gorunumu, acik/kapaliya gore egilir. */\nexport function SwitchLeverToggle(props: ToggleProps) {\n  const { on, toggle, spring } = useToggle(props)\n  const reduce = useReducedMotion()\n  const size = props.size ?? \"md\"\n  return (\n    <button\n      type=\"button\"\n      role=\"switch\"\n      aria-checked={on}\n      data-slot=\"styled-toggle\"\n      onClick={toggle}\n      className={cn(trackBase, trackSize[size], \"rounded-md transition-colors\", on ? \"justify-end bg-success\" : \"justify-start bg-input\", props.className)}\n      style={{ boxShadow: \"inset 0 1px 3px 0 color-mix(in oklab, var(--foreground) 25%, transparent)\" }}\n      {...stripToggleProps(props)}\n    >\n      <motion.span\n        layout\n        transition={spring}\n        animate={reduce ? undefined : { rotate: on ? 8 : -8 }}\n        className={cn(thumbSize[size], \"rounded-[3px] bg-background\")}\n        style={{ boxShadow: \"0 2px 3px 0 color-mix(in oklab, var(--foreground) 30%, transparent), inset 0 1px 0 0 color-mix(in oklab, var(--background) 90%, transparent)\" }}\n      />\n    </button>\n  )\n}\n",
      "type": "registry:component",
      "target": "components/ui/toggles-3d.tsx"
    }
  ],
  "categories": [
    "styled",
    "toggles"
  ],
  "type": "registry:component"
}