{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "dependencies": [
    "@base-ui/react@1.8.0"
  ],
  "description": "A toggle whose thumb squashes as it travels.",
  "docs": "Two steps after installing: import the copied stylesheet once at your app entry — it lands at `styles/liquefy-ui.css` — or `@import` it from your global CSS *before* `tailwindcss`, so Tailwind utilities keep winning over component styles. Then wrap the tree in `<LiquefyProvider>`, which is where every component reads its tokens from. Every copied file already carries its own 'use client' directive. Full documentation: https://liquefy-ui.com/#/docs/installation",
  "files": [
    {
      "content": "'use client'\n\nimport { Switch } from '@base-ui/react/switch'\nimport { forwardRef, useState, type ButtonHTMLAttributes } from 'react'\nimport { useLiquefyConfig } from '@/lib/provider'\nimport { useLiquidStyles, type LiquidStyleProps } from '@/lib/styles-prop'\nimport { useLiquidGlass } from '@/hooks/use-liquid-glass'\n\n// Base UI renders a hidden checkbox beside the button, so the switch finally\n// submits with a form and reports itself to a `<label>` the way a native\n// control does. The button is kept as the rendered element because the shader\n// canvas and the thumb live inside it.\n\nexport type LiquidSwitchProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onChange'> & LiquidStyleProps & {\n  checked?: boolean\n  defaultChecked?: boolean\n  label: string\n  onCheckedChange?: (checked: boolean) => void\n}\n\nexport const LiquidSwitch = forwardRef<HTMLButtonElement, LiquidSwitchProps>(({\n  checked,\n  className,\n  defaultChecked = false,\n  disabled,\n  label,\n  onCheckedChange,\n  style,\n  styles,\n  ...props\n}, forwardedRef) => {\n  const config = useLiquefyConfig()\n  // The thumb has a resting position for each state, so the springy hop between\n  // them has to stay off until the first flick — otherwise every switch that\n  // starts on animates itself on as the page loads.\n  const [hasInteracted, setHasInteracted] = useState(false)\n  const [elementRef, canvasRef] = useLiquidGlass(forwardedRef, {\n    bounce: 0.06,\n    disabled,\n    glow: config.glow,\n    intensity: config.intensity,\n    lens: config.lens && config.transparency,\n    lensStrength: config.refraction,\n    motion: config.motion,\n    ripple: config.ripple,\n    shimmer: config.shimmer,\n    sparkle: config.sparkle,\n    tilt: 0,\n    tint: config.tint,\n    webgl: config.webgl,\n    wobbliness: config.wobbliness,\n  })\n  const root = useLiquidStyles('lq-switch', { className, style, styles })\n\n  return (\n    <Switch.Root\n      aria-label={label}\n      checked={checked}\n      className={root.className}\n      data-interacted={hasInteracted || undefined}\n      defaultChecked={defaultChecked}\n      disabled={disabled}\n      nativeButton\n      onCheckedChange={(nextChecked) => {\n        setHasInteracted(true)\n        onCheckedChange?.(nextChecked)\n      }}\n      ref={elementRef}\n      render={<button type=\"button\" />}\n      style={root.style}\n      // `render` swaps the span Base UI would have made for a button, but the\n      // prop types still describe the span. The cast is that swap, written down.\n      {...(props as Switch.Root.Props)}\n    >\n      {config.webgl && <canvas aria-hidden=\"true\" className=\"lq-surface__shader\" ref={canvasRef} />}\n      <Switch.Thumb className=\"lq-switch__thumb\" />\n    </Switch.Root>\n  )\n})\n\nLiquidSwitch.displayName = 'LiquidSwitch'\n",
      "path": "registry/liquid-switch.tsx",
      "type": "registry:ui"
    }
  ],
  "name": "liquid-switch",
  "registryDependencies": [
    "https://liquefy-ui.com/r/liquefy-ui.json",
    "https://liquefy-ui.com/r/provider.json",
    "https://liquefy-ui.com/r/styles-prop.json",
    "https://liquefy-ui.com/r/use-liquid-glass.json"
  ],
  "title": "LiquidSwitch",
  "type": "registry:ui"
}
