MeshGradient
neon-ui/mesh-gradientFreeComponent
The Neon brand-deck gradient as a live WebGL surface: a defocused warm color field drifting over near-black.
Install it
npx shadcn@latest add https://ui.neon.com/r/mesh-gradient.jsonSource
1"use client";23/*4 * MeshGradient: the Neon brand-deck gradient as a live WebGL surface —5 * a defocused warm color field (moss, ember, gold, and a yellow-green6 * bloom) drifting over near-black. A brand background for heroes,7 * covers, and marketing moments. Static single frame under reduced8 * motion. GLSL lives in mesh-gradient-shader.ts.9 */1011import { useEffect, useRef } from "react";12import type { ComponentProps } from "react";1314import { cn } from "@/lib/utils";1516import { MESH_FRAGMENT, MESH_VERTEX } from "./mesh-gradient-shader";1718export type MeshGradientPalette = [19 base: string,20 moss: string,21 ember: string,22 gold: string,23 bloom: string,24];2526export type MeshGradientProps = Omit<ComponentProps<"canvas">, "children"> & {27 /** Animation speed multiplier; 0 freezes the field. */28 speed?: number;29 /** 0-1 domain warp — how organic the blob edges get. */30 warp?: number;31 /** 0-1 dither strength; keeps soft falloffs from banding. */32 grain?: number;33 /** Brightness multiplier on the bloom blob. */34 glow?: number;35 /** The field, painted back to front: [base, moss, ember, gold, bloom]. */36 colors?: MeshGradientPalette;37};3839/**40 * Seconds for a dial or palette change to close ~63% of its gap —41 * uniforms ease toward their targets each frame, so a dragged slider42 * or a palette switch glides instead of snapping.43 */44const SMOOTH_TAU = 0.12;4546const DEFAULT_COLORS: MeshGradientPalette = [47 "#0b0b08",48 "#2c4a33",49 "#a85f1b",50 "#edbf4e",51 "#eef2a0",52];5354const parseColor = (css: string): [number, number, number] => {55 const probe = document.createElement("canvas");56 probe.width = 1;57 probe.height = 1;58 const context = probe.getContext("2d");5960 if (!context) {61 return [0, 0, 0];62 }6364 context.fillStyle = css;65 context.fillRect(0, 0, 1, 1);66 const [r, g, b] = context.getImageData(0, 0, 1, 1).data;67 return [(r ?? 0) / 255, (g ?? 0) / 255, (b ?? 0) / 255];68};6970const warnDev = (message: string) => {71 if (typeof process !== "undefined" && process.env.NODE_ENV !== "production") {72 console.warn(message);73 }74};7576const compile = (77 gl: WebGLRenderingContext,78 type: number,79 source: string80): WebGLShader | null => {81 const shader = gl.createShader(type);8283 if (!shader) {84 return null;85 }8687 gl.shaderSource(shader, source);88 gl.compileShader(shader);8990 if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {91 warnDev(92 `neon-ui: shader compile failed: ${gl.getShaderInfoLog(shader) ?? "unknown"}`93 );94// … truncated
What it pulls in
Other registry items
Files it writes
More from neon-ui
All 77 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| ActivityFeedactivity-feed | neon-ui | Components | Free | 2 deps | |
| AgentChatagent-chat | neon-ui | Components | Free | 6 deps | |
| AnimatedWashanimated-wash | neon-ui | Components | Free | no deps · 2 files | |
| ApiKeyListapi-key-list | neon-ui | Components | Free | 2 deps | |
| AppCardapp-card | neon-ui | Components | Free | 2 deps | |
| AppCreatorapp-creator | neon-ui | Components | Free | 2 deps | |
| AuthFormauth-form | neon-ui | Components | Free | no deps | |
| AutoscaleChartautoscale-chart | neon-ui | Components | Free | 1 dep |
