Lab/12
Gradient Mesh
Five radial gradients at random points build a soft mesh. Regenerate until one works, then copy the CSS.
- Tool
- Color
Regenerate, then copy
lab/gradient-meshbackground-color: hsl(7 40% 97%); background-image: radial-gradient(at 14% 20%, hsl(7 86% 80%) 0px, transparent 55%), radial-gradient(at 84% 26%, hsl(30 90% 82%) 0px, transparent 55%), radial-gradient(at 28% 82%, hsl(340 80% 84%) 0px, transparent 55%), radial-gradient(at 74% 78%, hsl(215 85% 84%) 0px, transparent 55%), radial-gradient(at 52% 48%, hsl(42 92% 84%) 0px, transparent 55%);
Installation
Add Gradient Mesh to your project with the shadcn CLI. The files land in components/lab, ready to edit.
$ pnpm dlx shadcn@latest add @soultel/lab-gradient-meshOr by URL: https://asafefe.dev/r/lab-gradient-mesh.json
Brings along
- utils
Usage
import { GradientMesh, makeMeshBlobs, meshCss } from "@/components/lab/gradient-mesh"
const blobs = makeMeshBlobs("soft")
export function Example() {
return (
<GradientMesh blobs={blobs} className="h-64 rounded-xl p-6">
<h2>On a mesh</h2>
</GradientMesh>
)
}
// meshCss(blobs) returns the same mesh as plain CSS.Props
| Prop | Type | Default | Description |
|---|---|---|---|
| blobs | MeshBlob[] | DEFAULT_MESH | Positions and colors. Make new ones with makeMeshBlobs(tone). |
| tone | "soft" | "vivid" | "soft" | Pale or stronger base color. |
| ...props | ComponentProps<"div"> | - | Any div props. Children render on top. |
