{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "metal-button",
  "title": "Metal Button",
  "description": "Dark buttons ringed in moving chrome, or solid brushed silver.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "utils"
  ],
  "files": [
    {
      "path": "components/ui/metal-button.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { motion, useReducedMotion, type HTMLMotionProps } from \"motion/react\"\n\nimport { LiquidMetal, MetalRim } from \"@/components/ui/liquid-metal\"\nimport { cn } from \"@/lib/utils\"\n\nconst sizes = {\n  sm: \"h-9 gap-1.5 px-4 text-[13px] [&_svg]:size-3.5\",\n  md: \"h-10 gap-2 px-5 text-sm [&_svg]:size-4\",\n  lg: \"h-12 gap-2.5 px-6 text-[15px] [&_svg]:size-[18px]\",\n}\n\ntype MetalButtonProps = Omit<HTMLMotionProps<\"button\">, \"children\"> & {\n  /** rim is a dark button ringed in flowing chrome; silver is solid brushed metal */\n  variant?: \"rim\" | \"silver\"\n  size?: keyof typeof sizes\n  children?: React.ReactNode\n}\n\nfunction MetalButton({\n  variant = \"rim\",\n  size = \"md\",\n  className,\n  children,\n  type = \"button\",\n  ...props\n}: MetalButtonProps) {\n  const reduceMotion = useReducedMotion()\n  const silver = variant === \"silver\"\n\n  return (\n    <motion.button\n      data-slot=\"metal-button\"\n      data-variant={variant}\n      type={type}\n      className={cn(\n        \"relative isolate inline-flex shrink-0 cursor-pointer items-center justify-center rounded-full font-medium whitespace-nowrap outline-none select-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-60\",\n        \"shadow-[0_8px_24px_-12px_oklch(0_0_0/70%),0_1px_2px_oklch(0_0_0/40%)]\",\n        silver\n          ? \"text-[oklch(0.2_0.004_285)] [text-shadow:0_1px_0_oklch(1_0_0/45%)]\"\n          : \"bg-[linear-gradient(oklch(0.21_0.004_285),oklch(0.13_0.004_285))] text-white\",\n        sizes[size],\n        className\n      )}\n      whileTap={{ scale: reduceMotion ? 1 : 0.97 }}\n      transition={{ type: \"spring\", duration: 0.22, bounce: 0 }}\n      {...props}\n    >\n      {silver ? (\n        <LiquidMetal className=\"-z-10\" softness={1} brightness={0.8} scale={0.4} tint={[1, 0.92, 0.84]} />\n      ) : (\n        <MetalRim className=\"-z-10\" width={2} />\n      )}\n      {/* a bevel: light along the top edge, shade along the bottom */}\n      <span\n        aria-hidden\n        className={cn(\n          \"pointer-events-none absolute rounded-[inherit]\",\n          silver\n            ? \"inset-0 shadow-[inset_0_1px_0_oklch(1_0_0/60%),inset_0_-1px_0_oklch(0_0_0/20%)]\"\n            : \"inset-[2px] shadow-[inset_0_1px_0_oklch(1_0_0/12%)]\"\n        )}\n      />\n      <span className=\"relative inline-flex items-center gap-[inherit]\">{children}</span>\n    </motion.button>\n  )\n}\n\nexport { MetalButton, type MetalButtonProps }\n",
      "type": "registry:ui"
    },
    {
      "path": "components/ui/liquid-metal.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { useReducedMotion } from \"motion/react\"\n\nimport { ringMask } from \"@/lib/afterglow\"\nimport { cn } from \"@/lib/utils\"\n\n/*\n * Liquid metal: a slowly flowing metal surface, drawn by a small WebGL shader.\n * The surface is sine waves bent by other sine waves; each pixel reflects a\n * photo-studio backdrop (dark floor, bright horizon), which reads as metal.\n * Softness blurs that horizon, turning mirror chrome into brushed satin.\n *\n * Every piece on the page shares one WebGL context: it draws each piece in\n * turn and copies the frame into that piece's own canvas. Browsers cap live\n * contexts at about 16, so this keeps any number of pieces running.\n */\n\nconst VERTEX = `\nattribute vec2 position;\nvarying vec2 vUv;\nvoid main() {\n  vUv = position * 0.5 + 0.5;\n  gl_Position = vec4(position, 0.0, 1.0);\n}`\n\nconst FRAGMENT = `\nprecision highp float;\nvarying vec2 vUv;\nuniform vec2 uResolution;\nuniform float uTime;\nuniform vec3 uTint;\nuniform float uBrightness;\nuniform float uScale;\nuniform float uSoftness;\nuniform float uSilk;\n\n// round ripples, like a pool of mercury\nfloat liquid(vec2 p, float t) {\n  vec2 q = p;\n  q += 0.55 * vec2(sin(q.y * 1.3 + t * 1.1), sin(q.x * 1.1 - t * 0.9));\n  q += 0.28 * vec2(sin(q.y * 2.3 - t * 0.7), sin(q.x * 2.1 + t * 1.3));\n  return 0.5 * sin(q.x * 1.4 + t * 0.4) + 0.5 * sin(q.y * 1.7 - t * 0.3);\n}\n\n// long diagonal folds, like draped silk\nfloat silk(vec2 p, float t) {\n  vec2 d = normalize(vec2(1.0, 0.55));\n  float u = dot(p, d);\n  float v = dot(p, vec2(-d.y, d.x));\n  float w = u + 0.45 * sin(v * 0.9 + t * 0.8) + 0.2 * sin(v * 2.1 - t * 0.6);\n  return 0.65 * sin(w * 1.7 + t * 0.35) + 0.35 * sin(w * 3.1 - v * 0.4 - t * 0.25);\n}\n\nfloat height(vec2 p, float t) {\n  return mix(liquid(p, t), silk(p, t), uSilk);\n}\n\nfloat studio(float y, float soft) {\n  float edge = mix(0.03, 0.5, soft);\n  float ground = 0.05 + 0.12 * smoothstep(-1.2, -0.15, y);\n  float sky = 0.5 + 0.42 * smoothstep(0.05, 1.0, y);\n  float v = mix(ground, sky, smoothstep(-edge, edge, y));\n  v += mix(0.75, 0.28, soft) * exp(-pow((y - 0.03) * mix(26.0, 3.0, soft), 2.0));\n  v += 0.2 * exp(-pow((y - 0.6) * 8.0, 2.0));\n  return v;\n}\n\nvoid main() {\n  vec2 p = (vUv - 0.5) * vec2(uResolution.x / uResolution.y, 1.0) * 2.2 * uScale;\n  float t = uTime * 0.25;\n  float e = 0.01;\n  float h = height(p, t);\n  float dx = (height(p + vec2(e, 0.0), t) - h) / e;\n  float dy = (height(p + vec2(0.0, e), t) - h) / e;\n  float k = mix(0.8, 0.32, uSoftness);\n  vec3 n = normalize(vec3(-dx * k, -dy * k, 1.0));\n  vec3 r = reflect(vec3(0.0, 0.0, -1.0), n);\n  float y = r.y * 1.1 + p.y * 0.12 + 0.12 + uBrightness;\n  float v = studio(y, uSoftness) + mix(0.3, 0.12, uSoftness) * pow(max(r.x, 0.0), 5.0);\n  vec3 color = vec3(v);\n  color = mix(color, color * uTint, 0.4 * smoothstep(0.35, 1.0, v));\n  gl_FragColor = vec4(color, 1.0);\n}`\n\n// shown before the first frame, and wherever WebGL isn't available\nconst CHROME_FALLBACK =\n  \"conic-gradient(from 200deg at 35% 45%, #18181b, #e9e2da 14%, #2a2a2e 27%, #a29c95 41%, #141416 55%, #f3ece4 69%, #38383c 83%, #18181b)\"\nconst SATIN_FALLBACK =\n  \"linear-gradient(155deg, #2a2a2e, #8d8984 40%, #d6d1cb 52%, #5a5a5e 75%, #1c1c1f)\"\n\ntype Settings = {\n  speed: number\n  tint: [number, number, number]\n  brightness: number\n  scale: number\n  softness: number\n  silk: number\n  maxAspect: number\n  still: boolean\n}\n\ntype Piece = {\n  canvas: HTMLCanvasElement\n  context: CanvasRenderingContext2D\n  settings: Settings\n  start: number\n  visible: boolean\n  painted: boolean\n}\n\ntype Renderer = {\n  canvas: HTMLCanvasElement\n  gl: WebGLRenderingContext\n  uniforms: Record<string, WebGLUniformLocation | null>\n}\n\nconst pieces = new Set<Piece>()\nlet renderer: Renderer | null = null\nlet unavailable = false\nlet frame = 0\n\nfunction createRenderer(): Renderer | null {\n  const canvas = document.createElement(\"canvas\")\n  const gl = canvas.getContext(\"webgl\", { antialias: false, alpha: false })\n  if (!gl) return null\n  const compile = (type: number, source: string) => {\n    const shader = gl.createShader(type)!\n    gl.shaderSource(shader, source)\n    gl.compileShader(shader)\n    return shader\n  }\n  const program = gl.createProgram()!\n  gl.attachShader(program, compile(gl.VERTEX_SHADER, VERTEX))\n  gl.attachShader(program, compile(gl.FRAGMENT_SHADER, FRAGMENT))\n  gl.linkProgram(program)\n  if (!gl.getProgramParameter(program, gl.LINK_STATUS)) return null\n  gl.useProgram(program)\n  // one triangle that covers the whole viewport\n  gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer())\n  gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 3, -1, -1, 3]), gl.STATIC_DRAW)\n  const position = gl.getAttribLocation(program, \"position\")\n  gl.enableVertexAttribArray(position)\n  gl.vertexAttribPointer(position, 2, gl.FLOAT, false, 0, 0)\n  const names = [\"uResolution\", \"uTime\", \"uTint\", \"uBrightness\", \"uScale\", \"uSoftness\", \"uSilk\"]\n  const uniforms = Object.fromEntries(names.map((name) => [name, gl.getUniformLocation(program, name)]))\n\n  canvas.addEventListener(\"webglcontextlost\", (event) => {\n    event.preventDefault()\n    cancelAnimationFrame(frame)\n    frame = 0\n    renderer = null\n    for (const piece of pieces) {\n      piece.painted = false\n      piece.canvas.style.opacity = \"0\"\n    }\n    // build a fresh context once the browser has recovered\n    window.setTimeout(wake, 1000)\n  })\n  return { canvas, gl, uniforms }\n}\n\nfunction paint(piece: Piece, now: number) {\n  const { canvas, gl, uniforms } = renderer!\n  const { width, height } = piece.canvas\n  // the shared canvas only grows, and each piece draws into its bottom-left corner\n  if (canvas.width < width || canvas.height < height) {\n    canvas.width = Math.max(canvas.width, width)\n    canvas.height = Math.max(canvas.height, height)\n  }\n  const s = piece.settings\n  gl.viewport(0, 0, width, height)\n  gl.uniform2f(uniforms.uResolution, width, height)\n  // under reduced motion, hold one pleasing frame\n  gl.uniform1f(uniforms.uTime, s.still ? 3 : ((now - piece.start) / 1000) * s.speed + 3)\n  gl.uniform3f(uniforms.uTint, ...s.tint)\n  gl.uniform1f(uniforms.uBrightness, s.brightness)\n  // past maxAspect, ripples stretch across wide shapes instead of repeating\n  const aspect = width / height\n  gl.uniform1f(uniforms.uScale, s.maxAspect && aspect > s.maxAspect ? (s.scale * s.maxAspect) / aspect : s.scale)\n  gl.uniform1f(uniforms.uSoftness, s.softness)\n  gl.uniform1f(uniforms.uSilk, s.silk)\n  gl.drawArrays(gl.TRIANGLES, 0, 3)\n  piece.context.drawImage(canvas, 0, canvas.height - height, width, height, 0, 0, width, height)\n  piece.painted = true\n  piece.canvas.style.opacity = \"1\"\n}\n\nfunction tick(now: number) {\n  frame = 0\n  if (!renderer) return\n  let moving = false\n  for (const piece of pieces) {\n    if (!piece.visible || piece.canvas.width < 2) continue\n    if (piece.settings.still && piece.painted) continue\n    paint(piece, now)\n    if (!piece.settings.still) moving = true\n  }\n  if (moving) frame = requestAnimationFrame(tick)\n}\n\nfunction wake() {\n  if (frame || unavailable) return\n  if (!renderer) {\n    renderer = createRenderer()\n    if (!renderer) {\n      unavailable = true\n      return\n    }\n  }\n  frame = requestAnimationFrame(tick)\n}\n\ntype LiquidMetalProps = React.ComponentProps<\"div\"> & {\n  /** 1 is a slow drift */\n  speed?: number\n  /** warms or cools the highlights, as r, g, b from 0 to 1 */\n  tint?: [number, number, number]\n  /** 0.5 renders at half resolution, plenty for thin rims */\n  quality?: number\n  /** shifts the reflection toward the bright sky; 0.8 is mostly silver */\n  brightness?: number\n  /** below 1 makes the ripples broader, good for small or wide shapes */\n  scale?: number\n  /** 0 is mirror chrome, 1 is soft brushed satin */\n  softness?: number\n  /** \"silk\" lays the ripples out as long diagonal folds */\n  pattern?: \"liquid\" | \"silk\"\n  /** wider than this width-to-height ratio, ripples stretch instead of repeating */\n  maxAspect?: number\n}\n\nfunction LiquidMetal({\n  speed = 1,\n  tint = [1, 0.82, 0.66],\n  quality = 1,\n  brightness = 0,\n  scale = 1,\n  softness = 0,\n  pattern = \"liquid\",\n  maxAspect = 0,\n  className,\n  style,\n  ...props\n}: LiquidMetalProps) {\n  const reduceMotion = useReducedMotion()\n  const rootRef = React.useRef<HTMLDivElement>(null)\n  const [r, g, b] = tint\n\n  React.useEffect(() => {\n    const root = rootRef.current\n    if (!root) return\n    const canvas = document.createElement(\"canvas\")\n    canvas.className = \"absolute inset-0 size-full opacity-0 transition-opacity duration-300\"\n    const context = canvas.getContext(\"2d\", { alpha: false })\n    if (!context) return\n    root.appendChild(canvas)\n\n    const piece: Piece = {\n      canvas,\n      context,\n      settings: {\n        speed,\n        tint: [r, g, b],\n        brightness,\n        scale,\n        softness,\n        silk: pattern === \"silk\" ? 1 : 0,\n        maxAspect,\n        still: !!reduceMotion,\n      },\n      start: performance.now(),\n      visible: false,\n      painted: false,\n    }\n    pieces.add(piece)\n\n    const visibility = new IntersectionObserver(([entry]) => {\n      piece.visible = entry.isIntersecting\n      if (piece.visible) wake()\n    })\n    visibility.observe(canvas)\n\n    const sizing = new ResizeObserver(() => {\n      const ratio = Math.min(window.devicePixelRatio || 1, 2) * quality\n      canvas.width = Math.max(1, Math.round(canvas.clientWidth * ratio))\n      canvas.height = Math.max(1, Math.round(canvas.clientHeight * ratio))\n      // resizing clears the canvas, so paint again\n      piece.painted = false\n      wake()\n    })\n    sizing.observe(canvas)\n\n    return () => {\n      visibility.disconnect()\n      sizing.disconnect()\n      pieces.delete(piece)\n      canvas.remove()\n    }\n  }, [b, brightness, g, maxAspect, pattern, quality, r, reduceMotion, scale, softness, speed])\n\n  return (\n    <div\n      ref={rootRef}\n      data-slot=\"liquid-metal\"\n      aria-hidden\n      className={cn(\"pointer-events-none absolute inset-0 overflow-hidden rounded-[inherit]\", className)}\n      style={{ background: softness >= 0.5 ? SATIN_FALLBACK : CHROME_FALLBACK, ...style }}\n      {...props}\n    />\n  )\n}\n\ntype MetalRimProps = Omit<React.ComponentProps<\"span\">, \"children\"> & {\n  /** thickness of the ring in px */\n  width?: number\n  brightness?: number\n  quality?: number\n}\n\n/*\n * A hairline of chrome around its parent (give the parent a radius and\n * position). A steady edge, lit from above, sits under the moving metal; the\n * metal is screen-blended on top, so its dark patches never break the ring.\n */\nfunction MetalRim({ width = 1, brightness = 0.35, quality = 0.6, className, style, ...props }: MetalRimProps) {\n  return (\n    <span\n      aria-hidden\n      data-slot=\"metal-rim\"\n      className={cn(\"pointer-events-none absolute inset-0 rounded-[inherit]\", className)}\n      style={{ ...ringMask, padding: width, ...style }}\n      {...props}\n    >\n      <span className=\"absolute inset-0 rounded-[inherit] bg-[linear-gradient(180deg,oklch(0.78_0.01_80),oklch(0.36_0.004_285)_40%,oklch(0.3_0.004_285)_70%,oklch(0.55_0.006_80))]\" />\n      <LiquidMetal className=\"mix-blend-screen\" quality={quality} brightness={brightness} maxAspect={3.2} />\n    </span>\n  )\n}\n\nexport { LiquidMetal, MetalRim, type LiquidMetalProps, type MetalRimProps }\n",
      "type": "registry:ui"
    },
    {
      "path": "lib/afterglow.ts",
      "content": "import type { CSSProperties } from \"react\"\nimport type { TargetAndTransition, Transition } from \"motion/react\"\n\n// shared spring presets, every component picks from these\nexport const springs = {\n  snappy: { stiffness: 520, damping: 34, mass: 0.6 },\n  soft: { stiffness: 260, damping: 26, mass: 0.8 },\n  glide: { stiffness: 120, damping: 20, mass: 1 },\n} as const\n\nexport type SpringName = keyof typeof springs\n\nexport function spring(name: SpringName): Transition {\n  return { type: \"spring\", ...springs[name] }\n}\n\n// how a glow fades once its source moves away: slow, with a long tail\nexport const afterglow = {\n  linger: 0.9,\n  ease: [0.22, 1, 0.36, 1],\n} as const satisfies { linger: number; ease: Transition[\"ease\"] }\n\n// paints only the padding ring of an element, used for glowing borders\nexport const ringMask: CSSProperties = {\n  WebkitMask:\n    \"linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0)\",\n  WebkitMaskComposite: \"xor\",\n  mask: \"linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0)\",\n  maskComposite: \"exclude\",\n}\n\n// small icon gestures, played when a control is pressed or selected\nexport const iconGestures = {\n  pop: { scale: [1, 1.2, 1] },\n  ring: { rotate: [0, -18, 14, -9, 4, 0], scale: [1, 1.12, 1] },\n  // a gear looks the same after half a turn, so it can rest there and snap back unseen\n  turn: { rotate: [0, 180], scale: [1, 1.12, 1] },\n  hop: { y: [0, -3, 0], scale: [1, 1.1, 1] },\n  nudge: { x: [0, 2.5, 0], scale: [1, 1.1, 1] },\n} satisfies Record<string, TargetAndTransition>\n\nexport type IconGesture = keyof typeof iconGestures\n\n// leaving a gesture is instant: every gesture already ends at, or looks like, its resting pose\nexport const iconRest: TargetAndTransition = { scale: 1, rotate: 0, x: 0, y: 0, transition: { duration: 0 } }\n",
      "type": "registry:lib"
    }
  ],
  "cssVars": {
    "theme": {
      "color-glow": "var(--glow)",
      "color-glow-foreground": "var(--glow-foreground)",
      "color-glow-2": "var(--glow-2)",
      "color-glow-3": "var(--glow-3)",
      "color-glass": "var(--glass)",
      "color-gloss-highlight": "var(--gloss-highlight)",
      "shadow-gloss": "inset 0 1px 0 0 var(--gloss-highlight), inset 0 -1px 0 0 var(--gloss-shade), 0 0 0 1px var(--gloss-edge), 0 1px 2px 0 var(--gloss-depth), 0 4px 12px -4px var(--gloss-depth)",
      "shadow-glass": "inset 0 1px 0 0 var(--gloss-highlight), inset 0 -10px 24px -18px var(--gloss-shade), inset 0 0 0 1px var(--gloss-edge), 0 2px 6px -1px var(--gloss-depth), 0 18px 40px -12px var(--gloss-depth)",
      "shadow-well": "inset 0 1px 3px 0 var(--gloss-depth), inset 0 0 0 1px var(--gloss-edge), 0 1px 0 0 var(--gloss-highlight)"
    },
    "light": {
      "glow": "oklch(0.7 0.19 45)",
      "glow-foreground": "oklch(0.22 0.05 40)",
      "glow-2": "oklch(0.64 0.22 12)",
      "glow-3": "oklch(0.56 0.21 300)",
      "glass": "oklch(1 0 0 / 55%)",
      "gloss-highlight": "oklch(1 0 0 / 95%)",
      "gloss-shade": "oklch(0.3 0.03 285 / 10%)",
      "gloss-depth": "oklch(0.32 0.03 285 / 20%)",
      "gloss-edge": "oklch(0.22 0.02 285 / 10%)",
      "liquid-tint": "oklch(1 0 0 / 18%)",
      "liquid-fallback": "oklch(1 0 0 / 55%)",
      "liquid-rim": "oklch(1 0 0 / 95%)",
      "liquid-edge": "oklch(0.2 0.02 285 / 10%)",
      "liquid-shadow": "oklch(0.22 0.02 285 / 26%)",
      "liquid-glow": "oklch(1 0 0 / 55%)",
      "liquid-shade": "oklch(0.25 0.03 285 / 14%)"
    },
    "dark": {
      "glow": "oklch(0.8 0.16 55)",
      "glow-foreground": "oklch(0.22 0.05 40)",
      "glow-2": "oklch(0.7 0.2 15)",
      "glow-3": "oklch(0.65 0.2 300)",
      "glass": "oklch(0.19 0 0 / 55%)",
      "gloss-highlight": "oklch(1 0 0 / 16%)",
      "gloss-shade": "oklch(0 0 0 / 30%)",
      "gloss-depth": "oklch(0.04 0 0 / 60%)",
      "gloss-edge": "oklch(1 0 0 / 9%)",
      "liquid-tint": "oklch(0.2 0 0 / 22%)",
      "liquid-fallback": "oklch(0.2 0 0 / 45%)",
      "liquid-rim": "oklch(1 0 0 / 60%)",
      "liquid-edge": "oklch(1 0 0 / 10%)",
      "liquid-shadow": "oklch(0 0 0 / 50%)",
      "liquid-glow": "oklch(1 0 0 / 24%)",
      "liquid-shade": "oklch(0 0 0 / 28%)"
    }
  },
  "type": "registry:ui"
}