{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"aurora-glow-button","type":"registry:component","title":"Aurora Glow Button","description":"A night-glass pill with a sliver of aurora under it, turning on a 60s clock that every button on the page shares, spreading on hover and sending a ring of light out on press.","dependencies":[],"registryDependencies":[],"files":[{"path":"components/viberdy/aurora-glow-button.tsx","content":"\"use client\";\n\nimport { useState } from \"react\";\nimport type { CSSProperties, KeyboardEvent as ReactKeyboardEvent, ReactNode } from \"react\";\n\n/**\n * AuroraGlowButton — a night-glass pill with a sliver of aurora under it.\n *\n * The under-glow turns through the palette on one 60s clock that every\n * button on the page shares (the phase comes from the page's own timeline),\n * so they glow in step. Hover or focus lets the glow spread (220ms); a\n * press sends a ring of light out from the pill (380ms); the top edge\n * carries a thin lit rim. Solid or quiet. Renders a link when given an\n * href, else a button.\n *\n * Part of the Aurora kit: a near-black night (#050608) lit by curtains of\n * aurora in mint #7cf5c4 and sky #38bdf8, a violet #a78bfa blend, a rose\n * #f472b6 crown and an indigo #5b6cc4 fringe, all on one 60s clock; Bricolage\n * Grotesque through var(--font-bricolage) for lit display type over Geist.\n * Respects prefers-reduced-motion. No dependencies beyond React. Paste it as\n * its own file: it repeats the kit's small helpers, which would clash in one\n * module. For the display face, load Bricolage Grotesque with next/font\n * (variable: \"--font-bricolage\") on a parent; elsewhere, load it with a\n * Google Fonts link or @fontsource and set --font-bricolage yourself.\n */\n\nconst SANS = 'var(--font-sans, \"Geist\", \"Inter\", ui-sans-serif, system-ui, sans-serif)';\n\nconst EASE = \"cubic-bezier(0.22, 1, 0.36, 1)\";\n\nconst HEX = /^#[0-9a-fA-F]{6}$/;\n\n/** The night the kit is set in. */\nconst SKY = {\n  ground: \"#050608\",\n  panel: \"#0a0d12\",\n  raised: \"#0f141a\",\n  ink: \"rgba(236,244,248,0.94)\",\n  ink2: \"rgba(236,244,248,0.64)\",\n  ink3: \"rgba(236,244,248,0.42)\",\n  line: \"rgba(236,244,248,0.08)\",\n  line2: \"rgba(236,244,248,0.16)\",\n  shadow: \"0 40px 100px -30px rgba(0,0,0,0.7)\",\n} as const;\n\n/**\n * The sky's colours by altitude: the core low in the curtain (two hues it\n * drifts between on the aurora clock), a violet blend above it, a rose crown\n * seen only in a strong display, and an indigo fringe under the lower border.\n */\nexport type AuPalette = { core: string; core2: string; blend: string; high: string; fringe: string };\n\nexport const AU_PALETTES = {\n  boreal: { core: \"#7cf5c4\", core2: \"#38bdf8\", blend: \"#a78bfa\", high: \"#f472b6\", fringe: \"#5b6cc4\" },\n  verdant: { core: \"#6ee7a0\", core2: \"#7cf5c4\", blend: \"#8fb4f0\", high: \"#e879b9\", fringe: \"#5b6cc4\" },\n  violet: { core: \"#a78bfa\", core2: \"#38bdf8\", blend: \"#c4a6fb\", high: \"#f472b6\", fringe: \"#4c5bb8\" },\n} as const satisfies Record<string, AuPalette>;\n\nexport type AuPaletteName = keyof typeof AU_PALETTES;\n\nfunction own<T extends object>(map: T, key: string): key is Extract<keyof T, string> {\n  return Object.prototype.hasOwnProperty.call(map, key);\n}\n\n/** A named palette, or boreal. */\nfunction paletteOf(name: string): AuPalette {\n  return own(AU_PALETTES, name) ? AU_PALETTES[name] : AU_PALETTES.boreal;\n}\n\nfunction rgbOf(hex: string): [number, number, number] {\n  const n = parseInt((HEX.test(hex) ? hex : \"#7cf5c4\").slice(1), 16);\n  return [(n >> 16) & 255, (n >> 8) & 255, n & 255];\n}\n\nfunction rgba(hex: string, a: number): string {\n  const [r, g, b] = rgbOf(hex);\n  return `rgba(${r},${g},${b},${a})`;\n}\n\n/**\n * The aurora clock: every lit part of the page reads one 60s cycle, so a\n * button, a rim and the sky drift together instead of breathing out of step.\n * The phase is the page's own timeline (performance.now), shared by\n * everything on it.\n */\nconst CLOCK_S = 60;\n\n/**\n * A ref callback that starts an element's CSS animation where the clock\n * already is, so parts that mount at different moments stay in step.\n */\nfunction syncClock(periodS: number) {\n  return (el: HTMLElement | null) => {\n    if (el) el.style.animationDelay = `${(-(performance.now() / 1000) % periodS).toFixed(3)}s`;\n  };\n}\n\n/** Links: strip tabs and newlines, refuse backslashes, allow http(s), mailto, tel and same-site paths. */\nfunction safeHref(raw: string): string {\n  const v = raw.replace(/[\\t\\n\\r]/g, \"\").trim();\n  if (!v || v.includes(\"\\\\\")) return \"#\";\n  if (/^(https?:|mailto:|tel:)/i.test(v)) return v;\n  if (/^[/#?]/.test(v) && !/^\\/\\//.test(v)) return v;\n  return \"#\";\n}\n\n// Each part carries only the CSS it needs, so any one of them works on its own.\n// Nothing is interpolated into these sheets; colours arrive as CSS variables.\n// revert-layer keeps an element's own rounded corners when a host page's focus rule flattens them.\nconst FOCUS_CSS = \".au-scope :focus-visible,.au-scope:focus-visible{outline:2px solid var(--au-ring,#7cf5c4);outline-offset:3px;border-radius:revert-layer}\";\n\n/** The palette as CSS variables, for the parts drawn in CSS. */\nfunction paletteVars(p: AuPalette): CSSProperties {\n  return { \"--au-core\": p.core, \"--au-core2\": p.core2, \"--au-blend\": p.blend, \"--au-high\": p.high, \"--au-ring\": p.core } as CSSProperties;\n}\n\n// A registered angle, so the under-glow turns on the compositor without a render per frame.\nconst GLOW_BTN_CSS =\n  \"@property --au-a{syntax:'<angle>';inherits:false;initial-value:0deg}\" +\n  \"@keyframes au-turn{to{--au-a:360deg}}\" +\n  \"@keyframes au-ring{from{opacity:.9;transform:scale(1)}to{opacity:0;transform:scale(1.18,1.5)}}\" +\n  \".au-glow{inset:-6px -8px -12px;opacity:.55;animation:au-turn 60s linear infinite}\" +\n  \".au-btn:hover .au-glow,.au-btn:focus-visible .au-glow{inset:-12px -14px -18px;opacity:.85}\" +\n  \".au-q .au-glow{opacity:0}.au-q:hover .au-glow,.au-q:focus-visible .au-glow{opacity:.4}\" +\n  \".au-btn:active{transform:translateY(1px) scale(.985)}\" +\n  \"@media (prefers-reduced-motion: reduce){.au-glow{animation:none}.au-ring{animation:none!important;opacity:0}}\";\n\nexport type AuroraGlowButtonProps = {\n  children: ReactNode;\n  /** Renders a link when given, else a button. */\n  href?: string;\n  onClick?: () => void;\n  type?: \"button\" | \"submit\";\n  /** \"solid\" carries the sky under it; \"quiet\" is a hairline pill whose light wakes on hover. */\n  variant?: \"solid\" | \"quiet\";\n  size?: \"md\" | \"lg\";\n  palette?: AuPaletteName;\n  disabled?: boolean;\n  className?: string;\n};\n\n/**\n * A pill with a sliver of the sky under it. The under-glow is a slow turn\n * through the palette on the page's 60s aurora clock, so every button on the\n * page glows in step with the sky; hover or focus lets it spread (220ms), and\n * a press (or Enter or Space) sends a ring of light out from the pill (380ms). The top edge\n * carries a thin lit rim. Renders a link when given an href, else a button.\n */\nexport function AuroraGlowButton({ children, href, onClick, type = \"button\", variant = \"solid\", size = \"md\", palette = \"boreal\", disabled, className }: AuroraGlowButtonProps) {\n  const p = paletteOf(palette);\n  const [ring, setRing] = useState(0);\n  const solid = variant === \"solid\";\n  const cls =\n    \"au-scope au-btn relative isolate inline-flex select-none items-center justify-center gap-2 whitespace-nowrap rounded-full font-medium transition-[transform,color,box-shadow] duration-200 disabled:cursor-not-allowed disabled:opacity-50 \" +\n    (size === \"lg\" ? \"h-[52px] px-7 text-[15px]\" : \"h-11 px-5 text-[14px]\") +\n    (solid ? \"\" : \" au-q\") +\n    (className ? \" \" + className : \"\");\n  const style: CSSProperties = {\n    ...paletteVars(p),\n    color: SKY.ink,\n    fontFamily: SANS,\n    background: solid ? `linear-gradient(180deg, ${SKY.raised}, ${SKY.panel})` : \"transparent\",\n    boxShadow: solid ? `inset 0 0 0 1px ${SKY.line2}, 0 10px 30px -12px rgba(0,0,0,0.8)` : `inset 0 0 0 1px ${SKY.line2}`,\n  };\n  const sheet = <style>{FOCUS_CSS + GLOW_BTN_CSS}</style>;\n  const inner = (\n    <>\n      {/* The sky under the pill, turning on the aurora clock. */}\n      <span\n        ref={syncClock(CLOCK_S)}\n        aria-hidden\n        className=\"au-glow pointer-events-none absolute -z-10 rounded-full transition-[inset,opacity] duration-200\"\n        style={{\n          background: \"conic-gradient(from var(--au-a), var(--au-core), var(--au-core2), var(--au-blend), var(--au-core2), var(--au-core))\",\n          filter: \"blur(14px)\",\n        }}\n      />\n      {/* A lit rim along the top edge. */}\n      <span\n        aria-hidden\n        className=\"pointer-events-none absolute inset-0 rounded-full\"\n        style={{\n          padding: 1,\n          background: `linear-gradient(90deg, transparent 12%, ${rgba(p.core, solid ? 0.7 : 0.35)} 40%, ${rgba(p.core2, solid ? 0.6 : 0.3)} 62%, transparent 88%) top / 100% 1px no-repeat`,\n        }}\n      />\n      {ring > 0 && (\n        <span\n          key={ring}\n          aria-hidden\n          className=\"au-ring pointer-events-none absolute inset-0 rounded-full\"\n          style={{ boxShadow: `0 0 0 1px ${rgba(p.core, 0.8)}, 0 0 24px ${rgba(p.core2, 0.5)}`, animation: `au-ring 380ms ${EASE} both` }}\n        />\n      )}\n      <span className=\"relative\">{children}</span>\n    </>\n  );\n  const onDown = () => {\n    if (!disabled) setRing((r) => r + 1);\n  };\n  const onKey = (e: ReactKeyboardEvent) => {\n    if (!e.repeat && (e.key === \"Enter\" || e.key === \" \")) onDown();\n  };\n  if (href !== undefined) {\n    return (\n      <>\n        {sheet}\n        <a href={safeHref(href)} onClick={onClick} onPointerDown={onDown} onKeyDown={onKey} className={cls} style={style}>\n          {inner}\n        </a>\n      </>\n    );\n  }\n  return (\n    <>\n      {sheet}\n      <button type={type} onClick={onClick} onPointerDown={onDown} onKeyDown={onKey} disabled={disabled} className={cls} style={style}>\n        {inner}\n      </button>\n    </>\n  );\n}\n","type":"registry:component","target":"components/viberdy/aurora-glow-button.tsx"}],"meta":{"tier":"free","tags":["button","glow","aurora","conic","css","press"],"href":"https://viberdy.dev/library/aurora-glow-button","aiPrompt":"Build a React + Tailwind button, `AuroraGlowButton({ children, href, onClick, type, variant, size, palette, disabled })`.\n\nRegister --au-a as an <angle> with @property and turn it 0 to 360deg over 60s, linear. Start that animation where the page's clock already is: a ref callback sets animation-delay to -(performance.now() / 1000 % 60)s. Behind the pill a span (inset -6px -8px -12px, blur 14px, opacity 0.55) filled with conic-gradient(from var(--au-a), core, core2, blend, core2, core); on hover or focus-visible it grows to -12px -14px -18px at 0.85 in 220ms. The pill is dark glass (linear from #0f141a to #0a0d12, a 16% hairline) with a 1px lit rim across the top edge (a horizontal gradient of the core hues, fading at both ends). On pointerdown a keyed span with a core-coloured ring and glow scales to 1.18 x 1.5 and fades over 380ms. Quiet: transparent with the hairline, the glow at 0 until hover (0.4). Resting values live in the stylesheet, not inline, so hover can change them.\n\nAurora grammar: a near-black night #050608 (panels #0a0d12, raised #0f141a; ink #ecf4f8 at 94/64/42%; hairlines at 8% and 16%). The light is real aurora, coloured by altitude: a core in mint #7cf5c4 drifting toward sky #38bdf8 on one shared 60s clock, a violet #a78bfa blend above it, a rose #f472b6 crown seen only in a strong display, and an indigo #5b6cc4 fringe under the lower border (palettes: boreal, verdant #6ee7a0, violet). Never a hue-rotate cycle, never full-saturation rainbow; colour is a function of position and altitude, blended through noise. Curtains have a bright lower border, rays that rise and fray, folds that brighten where a sheet turns edge-on, and stretches that are lit and gone; layers are phase-offset, never in unison. A static 2% dither against banding (not re-seeded). Text never sits on bare aurora: frosted glass (blur 14-18px) or the dark between curtains. Bricolage Grotesque through var(--font-bricolage, \"Bricolage Grotesque\", ...) at 600-650 for lit display type only, Geist for UI, Geist Mono uppercase captions. Radii 20-24px on panels, pills for controls. Motion: the 60s aurora clock, ambient drifts of 30s and longer, discrete hover or focus changes under 450ms, pointer chases that settle over 600-900ms (1 - e^(-4dt)); WebGL runs at 30fps and only on screen. Every CSS-animated glow is started where the clock already is (a negative animation-delay from performance.now()), so parts mounted at different moments stay in step. Nothing interpolated into the small static <style> each part renders; colours arrive as CSS variables. Respect prefers-reduced-motion (still sky, no chases). No dependencies beyond React.","license":"https://viberdy.dev/license"}}