{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"neon-border","type":"registry:ui","title":"NeonBorder","description":"Two-colour neon tube around its content: two beams with white-hot cores chase each other along a faint tube, their glow spilling inside and outside the edge, humming slowly after a flicker on ignition","author":"fancy-ui <https://fancy-ui.rama.app>","categories":["effects"],"registryDependencies":["https://fancy-ui.rama.app/r/utils.json"],"files":[{"path":"react/src/components/neon-border/NeonBorder.tsx","content":"\"use client\";\n\nimport type { CSSProperties, HTMLAttributes, ReactNode } from \"react\";\nimport { cn } from \"../../utils\";\nimport \"./neon-border.css\";\n\n/**\n * NeonBorder - a two-colour neon tube around its content\n *\n * A faint tube runs all the way round; two beams, one per colour, chase\n * each other along it from opposite sides. Each beam has a white-hot core\n * and a coloured glow that spills both inside and outside the edge. The\n * glow hums (a slow breathing), and the tube flickers once as it ignites.\n */\nexport interface NeonBorderProps extends Omit<HTMLAttributes<HTMLDivElement>, \"className\"> {\n\t/** First neon color */\n\tcolor1?: string;\n\t/** Second neon color */\n\tcolor2?: string;\n\t/**\n\t * How much of the tube is lit: none (two short beams, static), half\n\t * (two short beams chasing), full (two long beams that nearly close the ring)\n\t */\n\tanimationType?: \"none\" | \"half\" | \"full\";\n\t/** Time for the beams to travel once around, in seconds */\n\tduration?: number;\n\t/** Additional CSS classes */\n\tclassName?: string;\n\t/** Content */\n\tchildren?: ReactNode;\n}\n\nexport type NeonAnimationType = NonNullable<NeonBorderProps[\"animationType\"]>;\n\n/** Share of the turn each beam covers, in %. */\nexport function beamArc(type: NeonAnimationType): number {\n\treturn type === \"full\" ? 46 : 22;\n}\n\n/**\n * The static tube (`animationType=\"none\"`): lit at two opposite corners,\n * the first colour top-left and the second bottom-right.\n */\nexport function neonCorners(color1: string, color2: string, core = false): string {\n\tconst tint = (c: string) => (core ? `color-mix(in srgb, ${c} 45%, #fff)` : c);\n\treturn `linear-gradient(135deg, ${tint(color1)} 0%, transparent 32%, transparent 68%, ${tint(color2)} 100%)`;\n}\n\n/**\n * The two beams as one conic gradient: each fades in from its tail and\n * cuts off sharply at its head, the second half a turn behind the first.\n * `core` whitens each colour for the hot centre of the tube.\n */\nexport function neonBeams(color1: string, color2: string, arc: number, core = false): string {\n\tconst tint = (c: string) => (core ? `color-mix(in srgb, ${c} 45%, #fff)` : c);\n\tconst beam = (c: string, from: number) => {\n\t\tconst head = from + arc;\n\t\treturn [\n\t\t\t`transparent ${from}%`,\n\t\t\t`color-mix(in srgb, ${tint(c)} 55%, transparent) ${(from + arc * 0.45).toFixed(1)}%`,\n\t\t\t`${tint(c)} ${(head - 0.6).toFixed(1)}%`,\n\t\t\t`transparent ${head.toFixed(1)}%`,\n\t\t].join(\", \");\n\t};\n\treturn `conic-gradient(from var(--neon-angle), ${beam(color1, 0)}, ${beam(color2, 50)}, transparent 100%)`;\n}\n\nfunction getWidth(type: NeonAnimationType): number {\n\tswitch (type) {\n\t\tcase \"none\":\n\t\t\treturn 12;\n\t\tcase \"half\":\n\t\t\treturn 50;\n\t\tcase \"full\":\n\t\t\treturn 100;\n\t}\n}\n\nexport function NeonBorder({\n\tcolor1 = \"#0496ff\",\n\tcolor2 = \"#ff0a54\",\n\tanimationType = \"half\",\n\tduration = 6,\n\tclassName,\n\tchildren,\n\tstyle,\n\t...rest\n}: NeonBorderProps) {\n\tconst arc = beamArc(animationType);\n\tconst animated = animationType !== \"none\";\n\n\tconst styleVars = {\n\t\t\"--neon-duration\": `${duration}s`,\n\t\t\"--neon-color1\": color1,\n\t\t\"--neon-color2\": color2,\n\t\t\"--neon-width\": `${getWidth(animationType)}%`,\n\t\t\"--neon-beams\": animated ? neonBeams(color1, color2, arc) : neonCorners(color1, color2),\n\t\t\"--neon-core\": animated\n\t\t\t? neonBeams(color1, color2, arc, true)\n\t\t\t: neonCorners(color1, color2, true),\n\t} as CSSProperties;\n\n\treturn (\n\t\t<div\n\t\t\t{...rest}\n\t\t\tclassName={cn(\n\t\t\t\t\"neon-border-container relative z-10 inline-block h-10 w-full max-w-sm rounded-lg p-px\",\n\t\t\t\tanimated && \"neon-animated\",\n\t\t\t\tclassName\n\t\t\t)}\n\t\t\tstyle={{ ...style, ...styleVars }}\n\t\t>\n\t\t\t{children}\n\n\t\t\t<span className=\"neon-tube\" aria-hidden=\"true\"></span>\n\t\t\t<span className=\"neon-light\" aria-hidden=\"true\">\n\t\t\t\t<span className=\"neon-glow\">\n\t\t\t\t\t<span></span>\n\t\t\t\t</span>\n\t\t\t\t<span className=\"neon-core\"></span>\n\t\t\t</span>\n\t\t</div>\n\t);\n}\n","type":"registry:ui","target":"@ui/fancy/components/neon-border/NeonBorder.tsx"},{"path":"react/src/components/neon-border/index.ts","content":"\"use client\";\n\nexport { NeonBorder } from \"./NeonBorder\";\nexport type { NeonBorderProps } from \"./NeonBorder\";\n","type":"registry:ui","target":"@ui/fancy/components/neon-border/index.ts"},{"path":"react/src/components/neon-border/neon-border.css","content":"/* Svelte scoped these rules; here every rule is anchored on the root class\n   `.neon-border-container` so nothing leaks into the consumer's page. */\n\n@property --neon-angle {\n\tsyntax: \"<angle>\";\n\tinherits: true;\n\tinitial-value: 135deg;\n}\n\n.neon-border-container {\n\t--neon-tube-width: 1.5px;\n\tpadding: var(--neon-tube-width);\n\tisolation: isolate;\n}\n\n.neon-border-container .neon-tube,\n.neon-border-container .neon-light,\n.neon-border-container .neon-glow,\n.neon-border-container .neon-glow > span,\n.neon-border-container .neon-core {\n\tposition: absolute;\n\tpointer-events: none;\n\tborder-radius: inherit;\n}\n\n/* keep only the padding ring: the element minus its content box */\n.neon-border-container .neon-tube,\n.neon-border-container .neon-glow > span,\n.neon-border-container .neon-core {\n\t-webkit-mask:\n\t\tlinear-gradient(#000 0 0) content-box,\n\t\tlinear-gradient(#000 0 0);\n\t-webkit-mask-composite: xor;\n\tmask:\n\t\tlinear-gradient(#000 0 0) content-box,\n\t\tlinear-gradient(#000 0 0);\n\tmask-composite: exclude;\n}\n\n/* The unlit tube: always there, faint, shading from one colour to the other. */\n.neon-border-container .neon-tube {\n\tinset: 0;\n\tpadding: var(--neon-tube-width);\n\tbackground: linear-gradient(\n\t\t135deg,\n\t\tcolor-mix(in srgb, var(--neon-color1) 30%, transparent),\n\t\tcolor-mix(in srgb, var(--neon-color2) 30%, transparent)\n\t);\n}\n\n.neon-border-container .neon-light {\n\tinset: 0;\n}\n\n/* The glow: the beams on a wide ring straddling the edge, blurred after\n   masking so it spills softly both inside and outside. */\n.neon-border-container .neon-glow {\n\tinset: 0;\n\tfilter: blur(7px);\n\t/* on a light page a coloured halo reads as a stain: keep it faint */\n\topacity: var(--neon-glow-max);\n}\n\n.neon-border-container {\n\t--neon-glow-max: 0.4;\n\t--neon-glow-min: 0.25;\n}\n\n.dark .neon-border-container {\n\t--neon-glow-max: 0.9;\n\t--neon-glow-min: 0.6;\n}\n\n.neon-border-container .neon-glow > span {\n\tinset: -7px;\n\tpadding: calc(var(--neon-tube-width) + 12px);\n\tborder-radius: calc(0.5rem + 7px);\n\tbackground: var(--neon-beams);\n}\n\n/* The white-hot core of the lit tube. */\n.neon-border-container .neon-core {\n\tinset: 0;\n\tpadding: var(--neon-tube-width);\n\tbackground: var(--neon-core);\n}\n\n@media (prefers-reduced-motion: no-preference) {\n\t/* The beams chase round the tube. */\n\t.neon-border-container.neon-animated {\n\t\tanimation: neon-travel var(--neon-duration) linear infinite;\n\t}\n\n\t/* The tube strikes once on first paint… */\n\t.neon-border-container .neon-light {\n\t\tanimation: neon-ignite 0.9s steps(1, end) both;\n\t}\n\n\t/* …then hums: a slow breathing of the glow. */\n\t.neon-border-container .neon-glow {\n\t\tanimation: neon-hum 2.8s ease-in-out 0.9s infinite alternate;\n\t}\n}\n\n@keyframes neon-travel {\n\tfrom {\n\t\t--neon-angle: 135deg;\n\t}\n\tto {\n\t\t--neon-angle: 495deg;\n\t}\n}\n\n@keyframes neon-ignite {\n\t0% {\n\t\topacity: 0;\n\t}\n\t10% {\n\t\topacity: 0.8;\n\t}\n\t18% {\n\t\topacity: 0.1;\n\t}\n\t30% {\n\t\topacity: 1;\n\t}\n\t40% {\n\t\topacity: 0.35;\n\t}\n\t52% {\n\t\topacity: 1;\n\t}\n\t100% {\n\t\topacity: 1;\n\t}\n}\n\n@keyframes neon-hum {\n\tfrom {\n\t\topacity: var(--neon-glow-max);\n\t}\n\tto {\n\t\topacity: var(--neon-glow-min);\n\t}\n}\n","type":"registry:ui","target":"@ui/fancy/components/neon-border/neon-border.css"}],"meta":{"license":"MIT","package":"fancy-ui-react","version":"0.7.0","source":"https://fancy-ui.rama.app/docs/components/neon-border?framework=react"}}