Updated
Dither Gradient
Customize
Colors
Pixel size3px
Scale1.00
Warp1.00
Angle90°
Sweep0.60
Speed1.0
Seed0
Radius180px
Follow0.60
Installation
npx shadcn@latest add https://uibrik.com/r/dither-gradient.jsonAdd the cn helper
Imports
cnfrom@/lib/utils, whichshadcn initcreates. Add it by hand without shadcn.Copy the source into your project
components/uibrik/dither-gradient/dither-gradient.tsx"use client"; import { ShaderSurface, type ShaderBackgroundProps } from "../_shader-background/ShaderSurface"; // A soft, slowly folding gradient drawn with nothing but the colours you give it: each pixel picks // one of them through an 8x8 ordered (Bayer) dither, so in-between tones become fine patterns. Big // pixels make it retro, small ones make it read as texture. The pointer lifts the tone toward the // last colour, trailing a little behind. const SHADER = /* glsl */ ` uniform float u_pixel; // dither pixel size, css px uniform float u_scale; // size of the shapes uniform float u_warp; // how much the gradient bends uniform float u_angle; // direction the colours run, degrees uniform float u_sweep; // how far apart the first and last colours sit uniform float u_radius; // reach of the pointer light, css px // threshold for an 8x8 Bayer matrix, 0..1; the lowest coordinate bits weigh the most float bayer8(vec2 p) { ivec2 i = ivec2(mod(p, 8.0)); int v = 0; for (int b = 0; b < 3; b++) { int x = (i.x >> b) & 1; int y = (i.y >> b) & 1; v = v * 4 + (((x ^ y) << 1) | y);
Adds the files to
components/uibrik/dither-gradient. With the @uibrik namespace set up: npx shadcn@latest add @uibrik/dither-gradient.Too large to paste whole, so Copy prompt gives a short prompt that installs it with the CLI. Download the full prompt to attach it instead.
Usage
import { DitherGradient } from "@/components/uibrik/dither-gradient/dither-gradient";const colors = ["#0f1535", "#2747c9", "#21b5a8", "#c8ec6e", "#f8f6e3"];<DitherGradient colors={colors} pixelSize={3} scale={1} warp={1} angle={90} sweep={0.6} speed={1} seed={0} animate interactive radius={180} follow={0.6}> …</DitherGradient>Where to use Dither Gradient
Retro brand backgrounds
An ordered dither drawn only in your colours gives a printed, 1-bit look that stays on brand.
Pairs with Halftone
Design tool heroes
A bending gradient with visible pixels signals craft to a design-literate audience.
Covers and dividers
The pattern works as a band between sections or as a cover image for posts.
Props
DitherGradient- colors
- Type string[]
- ["#0f1535","#2747c9","#21b5a8","#c8ec6e","#f8f6e3"]
- The only colours drawn, in order; 2 to 6.
- pixelSize
- Type number
- 3
- Size of a dither pixel; larger is more retro.
- scale
- Type number
- 1
- Size of the shapes; larger is calmer.
- warp
- Type number
- 1
- How much the gradient bends.
- angle
- Type number
- 90
- Direction the colours run; 90 runs bottom to top.
- sweep
- Type number
- 0.6
- How far apart the first and last colours sit.
- speed
- Type number
- 1
- Animation speed; 1 is the designed pace.
- seed
- Type number
- 0
- Shifts the composition, so two backgrounds with the same settings still differ.
- animate
- Type boolean
- true
- Move on its own. Off draws one still frame.
- interactive
- Type boolean
- true
- React to the pointer.
- radius
- Type number
- 180
- How far the pointer light reaches.
- follow
- Type number
- 0.6
- How lazily the light follows the pointer, 0 (locked) to 1 (drifts after it).
- children
- Type ReactNode
- –
- Content shown on top of the background.
- className
- Type string
- –
- Classes for the box; it fills whatever size you give it.