{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "button",
  "title": "Button",
  "description": "A native button with a dither or ASCII fill that eases fuller on hover and press.",
  "dependencies": [],
  "registryDependencies": [
    "https://dotgrain.space/r/engine.json"
  ],
  "files": [
    {
      "path": "registry/ui/button.tsx",
      "content": "\"use client\";\n\nimport { useState, type ComponentProps } from \"react\";\nimport { paletteColors } from \"@/lib/dotgrain/palettes\";\nimport { useColorScheme, useDitherTokens } from \"@/lib/dotgrain/provider\";\nimport { Quantize } from \"@/lib/dotgrain/quantize\";\nimport type { DitherTokens } from \"@/lib/dotgrain/types\";\n\nexport type ButtonProps = Omit<ComponentProps<\"button\">, keyof DitherTokens> &\n  Partial<DitherTokens> & {\n    /** Solid: filled face, fuller on hover. Outline: empty face with a border, filling on hover. */\n    variant?: \"solid\" | \"outline\";\n    size?: \"sm\" | \"md\" | \"lg\";\n  };\n\nconst SIZES = { sm: { padding: \"4px 10px\", fontSize: 13 }, md: { padding: \"8px 16px\", fontSize: 14 }, lg: { padding: \"12px 24px\", fontSize: 16 } };\n// Fill reach (progress field value) at rest, hovered and pressed; a 0.5 softness dithers the leading edge.\nconst FILL = { solid: [0.8, 1.6, 1.1], outline: [-0.5, 0.6, 0.35] };\n\nexport function Button({\n  variant = \"solid\",\n  size = \"md\",\n  mode, pattern, cell, palette, glyphs, speed, contrast, threshold,\n  disabled,\n  children,\n  style,\n  onPointerEnter, onPointerLeave, onPointerDown, onPointerUp,\n  ...props\n}: ButtonProps) {\n  const tokens = { mode, pattern, cell, palette, glyphs, speed, contrast, threshold };\n  const [state, setState] = useState(0);\n  const { scheme } = useColorScheme();\n  const colors = paletteColors(useDitherTokens(tokens).palette, scheme);\n  const [bg, fg] = [colors[0], colors[colors.length - 1]];\n  const solid = variant === \"solid\";\n  const fill = FILL[variant][disabled ? 0 : state];\n  return (\n    <button\n      type=\"button\"\n      {...props}\n      disabled={disabled}\n      onPointerEnter={(e) => (setState(1), onPointerEnter?.(e))}\n      onPointerLeave={(e) => (setState(0), onPointerLeave?.(e))}\n      onPointerDown={(e) => (setState(2), onPointerDown?.(e))}\n      onPointerUp={(e) => (setState(1), onPointerUp?.(e))}\n      style={{\n        position: \"relative\",\n        display: \"inline-flex\",\n        alignItems: \"center\",\n        justifyContent: \"center\",\n        border: `1px solid ${fg}`,\n        background: bg,\n        font: \"inherit\",\n        lineHeight: 1.2,\n        cursor: disabled ? \"not-allowed\" : \"pointer\",\n        opacity: disabled ? 0.5 : undefined,\n        ...SIZES[size],\n        ...style,\n      }}\n    >\n      <Quantize\n        source={{ kind: \"field\", field: \"progress\", params: { value: fill, softness: 0.5 } }}\n        ease\n        {...tokens}\n        style={{ position: \"absolute\", inset: 0, pointerEvents: \"none\" }}\n      />\n      {/* The label sits on a solid chip so it stays legible over any fill. */}\n      <span style={{ position: \"relative\", padding: \"0 0.25em\", background: solid ? fg : bg, color: solid ? bg : fg }}>{children}</span>\n    </button>\n  );\n}\n",
      "type": "registry:ui"
    }
  ],
  "meta": {
    "modes": [
      "dither",
      "ascii"
    ]
  },
  "categories": [
    "control"
  ],
  "type": "registry:ui"
}