Vibrant Grain
Vibrant grain texture: sparkling noise in three stacked turbulence layers, the top one at screen blend so it reads as silver-halide glints rather than surface texture. One strength value scales every layer.
import { cn } from "cn"
// Colored feTurbulence speckle; the top layer blends at `screen`, which
// reads as silver-halide sparkle rather than surface texture.
const WHITE_COARSE = `url("data:image/svg+xml,%3Csvg viewBox='0 0 800 800' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='vg1'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='3.5' numOctaves='10' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23vg1)' fill='white'/%3E%3C/svg%3E")`
const WHITE_FINE = `url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='vg2'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='5.5' numOctaves='8' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23vg2)' fill='white'/%3E%3C/svg%3E")`
const WHITE_MICRO = `url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='vg3'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='7.0' numOctaves='6' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23vg3)' fill='white'/%3E%3C/svg%3E")`
const LAYERS = [
{
src: WHITE_COARSE,
size: "600px 600px",
opacity: 0.8,
blend: "mix-blend-overlay",
},
{
src: WHITE_FINE,
size: "300px 300px",
opacity: 0.7,
blend: "mix-blend-soft-light",
},
{
src: WHITE_MICRO,
size: "150px 150px",
opacity: 0.5,
blend: "mix-blend-screen",
},
]
/**
* Colored film-grain speckle in layers, laid over the art in a full-bleed,
* click-through layer. It is decorative and hidden from assistive tech.
*/
function VibrantGrain({
strength = 1,
className,
...props
}: React.ComponentProps<"div"> & {
/**
* Scales every layer together; 1 is the tuned setting. Above ~1.25 the top
* layer clamps at opacity 1 while the others keep climbing, which inverts
* the balance the stack was tuned for.
*/
strength?: number
}) {
return (
<div
data-slot="vibrant-grain"
aria-hidden="true"
className={cn("pointer-events-none absolute inset-0", className)}
{...props}
>
{LAYERS.map((layer, i) => (
<div
key={i}
className={cn("absolute inset-0", layer.blend)}
style={{
backgroundImage: layer.src,
backgroundSize: layer.size,
opacity: Math.min(1, layer.opacity * strength),
}}
/>
))}
</div>
)
}
export { VibrantGrain }
import { SideGlow } from "@/components/glow/side-glow"
import { Subheading } from "@/components/subheading/subheading"
import { VibrantGrain } from "@/components/texture/vibrant-grain"
const COPY = {
title: "Night notes",
body: "Written after sundown.",
} as const
export default function VibrantGrainDemo() {
return (
<div className="flex min-h-full w-full flex-1 items-center justify-center p-6">
<article className="relative isolate flex aspect-4/3 w-full max-w-96 flex-col justify-end overflow-hidden rounded-3xl bg-[oklch(0.372_0.044_257.3)] p-8 text-scene-foreground">
<SideGlow />
{/* Its screen layer brightens the card; at 0.45 the white copy keeps
at least 4.5:1 contrast. */}
<VibrantGrain strength={0.45} />
<div className="relative">
<Subheading>{COPY.title}</Subheading>
<p className="mt-3 text-sm/6">{COPY.body}</p>
</div>
</article>
</div>
)
}
"use client"
import { useId } from "react"
import { cn } from "cn"
const EDGE = {
right: {
cx: "100%",
cy: "50%",
className: "top-[-40%] -right-40 h-[180%] w-7xl",
},
left: {
cx: "0%",
cy: "50%",
className: "top-[-40%] -left-40 h-[180%] w-7xl",
},
bottom: {
cx: "50%",
cy: "100%",
className: "-bottom-40 left-[-40%] h-320 w-[180%]",
},
top: {
cx: "50%",
cy: "0%",
className: "-top-40 left-[-40%] h-320 w-[180%]",
},
} as const
/**
* A soft blue glow that comes in from one edge of a section, for the
* background behind its content. Put it inside a positioned parent: it fills
* that parent, clips itself to it, ignores the pointer and is hidden from
* assistive tech.
*/
function SideGlow({
edge = "right",
className,
...props
}: React.ComponentProps<"div"> & {
/** The edge the glow comes in from. Defaults to "right". */
edge?: keyof typeof EDGE
}) {
// An id passed in names the root; the gradient keeps its own.
const gradientId = `side-glow-${useId().replace(/[^\w-]/g, "")}`
const anchor = EDGE[edge]
return (
<div
aria-hidden="true"
data-slot="side-glow"
className={cn(
"pointer-events-none absolute inset-0 overflow-hidden",
className
)}
{...props}
>
<svg
className={cn("absolute", anchor.className)}
preserveAspectRatio="none"
>
<defs>
<radialGradient id={gradientId} cx={anchor.cx} cy={anchor.cy}>
<stop offset="0%" stopColor="oklch(0.754 0.139 233 / 0.3)" />
<stop offset="53.95%" stopColor="oklch(0.511 0.274 264 / 0.09)" />
<stop offset="100%" stopColor="oklch(0.164 0.02 266 / 0)" />
</radialGradient>
</defs>
<rect width="100%" height="100%" fill={`url(#${gradientId})`} />
</svg>
</div>
)
}
/**
* A one-pixel vertical line of white, blended in overlay mode so it lightens
* the surface under it. It is decorative and hidden from assistive tech.
*
* It is absolutely positioned with no height of its own: place it with
* `className`, for example `inset-y-0 right-0`.
*/
function SeamLine({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
aria-hidden="true"
data-slot="seam-line"
className={cn(
"pointer-events-none absolute w-px bg-[oklch(1_0_0)] mix-blend-overlay",
className
)}
{...props}
/>
)
}
export { SideGlow, SeamLine }
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cn } from "cn"
// No width of its own: the SectionHeader column (or whatever holds it) is
// the measure. text-pretty keeps a wrapped title from ending on one word.
// font-display follows font-sans unless the block switches it, for example
// with [--font-display:var(--font-serif)].
/**
* The section heading in the display font, rendered as an `<h2>`: 30px with
* a 36px line, 40px with a 40px line from the `sm` breakpoint. One size, no
* props beyond the element's own; pass `render` to use another heading
* level. A page's headline is `Heading`.
*/
function Subheading({
className,
render,
...props
}: useRender.ComponentProps<"h2">) {
return useRender({
defaultTagName: "h2",
render,
state: { slot: "subheading" },
props: mergeProps<"h2">(
{
className: cn(
"font-display text-3xl/9 tracking-[-0.03em] text-pretty sm:text-[2.5rem]/10",
className
),
},
props
),
})
}
export { Subheading }
Installation
pnpm dlx shadcn@latest add @01orbital/vibrant-grainnpx shadcn@latest add @01orbital/vibrant-grainyarn dlx shadcn@latest add @01orbital/vibrant-grainbunx --bun shadcn@latest add @01orbital/vibrant-grainUsage
import { SideGlow } from "@/components/glow/side-glow"
import { Subheading } from "@/components/subheading/subheading"
import { VibrantGrain } from "@/components/texture/vibrant-grain"
const COPY = {
title: "Night notes",
body: "Written after sundown.",
} as const
export default function VibrantGrainDemo() {
return (
<div className="flex min-h-full w-full flex-1 items-center justify-center p-6">
<article className="relative isolate flex aspect-4/3 w-full max-w-96 flex-col justify-end overflow-hidden rounded-3xl bg-[oklch(0.372_0.044_257.3)] p-8 text-scene-foreground">
<SideGlow />
{/* Its screen layer brightens the card; at 0.45 the white copy keeps
at least 4.5:1 contrast. */}
<VibrantGrain strength={0.45} />
<div className="relative">
<Subheading>{COPY.title}</Subheading>
<p className="mt-3 text-sm/6">{COPY.body}</p>
</div>
</article>
</div>
)
}This example installs with everything it uses:
pnpm dlx shadcn@latest add @01orbital/vibrant-grain-demonpx shadcn@latest add @01orbital/vibrant-grain-demoyarn dlx shadcn@latest add @01orbital/vibrant-grain-demobunx --bun shadcn@latest add @01orbital/vibrant-grain-demoExamples
· Announcement pillvibrant-grain-announcement-pill
Vibrant Grain texture example: a dismissible pill-shaped announcement on a warm brown ground, with tonal grain under white speckle, a label, a message, a link and a close button. Use it for a site-wide notice.
"use client"
import { useState } from "react"
import { ArrowRightIcon, XIcon } from "@phosphor-icons/react"
import { Grain } from "@/components/texture/grain"
import { VibrantGrain } from "@/components/texture/vibrant-grain"
import { Button } from "@/components/ui/button"
// The copy: change text here, not in the markup.
const COPY = {
label: "New",
message: "A white-speckle grain, stacked on our tonal one.",
link: "See it",
dismiss: "Dismiss",
restore: "Show again",
} as const
/** A dismissible pill-shaped announcement on a warm ground, with tonal grain under white speckle. */
export default function VibrantGrainAnnouncementPill() {
const [shown, setShown] = useState(true)
if (!shown) {
return (
<Button variant="outline" onClick={() => setShown(true)}>
{COPY.restore}
</Button>
)
}
return (
<div className="relative isolate w-full overflow-hidden rounded-full text-[#f3e9dd]">
<div
aria-hidden="true"
className="pointer-events-none absolute inset-0 bg-[linear-gradient(135deg,#1a1512_0%,#2d2018_40%,#3a2a1d_70%,#4a3525_100%)] contain-[paint]"
>
<Grain variant="single" />
<VibrantGrain strength={0.4} />
</div>
<div className="relative flex items-center gap-4 py-2 pr-2 pl-5">
<span className="font-mono text-xs tracking-[0.18em] text-[#e9ddcf] uppercase">
{COPY.label}
</span>
<p className="flex-1 text-sm/6">{COPY.message}</p>
<a
href="#"
className="inline-flex items-center gap-1 text-sm font-medium underline underline-offset-4"
>
{COPY.link} <ArrowRightIcon className="size-4" />
</a>
<Button
variant="ghost"
size="icon-sm"
aria-label={COPY.dismiss}
onClick={() => setShown(false)}
className="text-[#f3e9dd] hover:bg-white/10 hover:text-[#f3e9dd]"
>
<XIcon />
</Button>
</div>
</div>
)
}
import { cn } from "cn"
// Paper grain: an SVG turbulence filter as a data URI.
const PAPER_GRAIN = `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='250' height='250' viewBox='0 0 100 100'%3E%3Cfilter id='n' color-interpolation-filters='sRGB'%3E%3CfeTurbulence type='turbulence' baseFrequency='1.4' numOctaves='1' seed='2' stitchTiles='stitch' result='n'/%3E%3CfeComponentTransfer result='g'%3E%3CfeFuncR type='linear' slope='4' intercept='1'/%3E%3CfeFuncG type='linear' slope='4' intercept='1'/%3E%3CfeFuncB type='linear' slope='4' intercept='1'/%3E%3C/feComponentTransfer%3E%3CfeColorMatrix type='saturate' values='0' in='g'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")`
// Sandpaper grain: an SVG turbulence filter as a data URI.
const SANDPAPER_GRAIN = `url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200' viewBox='0 0 100 100'%3E%3Cfilter id='n' color-interpolation-filters='sRGB'%3E%3CfeTurbulence type='turbulence' baseFrequency='2.2' numOctaves='2' seed='5' stitchTiles='stitch' result='n'/%3E%3CfeComponentTransfer result='g'%3E%3CfeFuncR type='linear' slope='2.5' intercept='0.8'/%3E%3CfeFuncG type='linear' slope='2.5' intercept='0.8'/%3E%3CfeFuncB type='linear' slope='2.5' intercept='0.8'/%3E%3C/feComponentTransfer%3E%3CfeColorMatrix type='saturate' values='0' in='g'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")`
// Single noise: an SVG turbulence filter as a data URI.
const SINGLE_NOISE = `url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n' color-interpolation-filters='sRGB'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")`
// Square grain: an SVG turbulence filter as a data URI.
const SQUARE_GRAIN = `url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20width=%22200%22%20height=%22200%22%20viewBox=%220%200%20100%20100%22%3E%3Cfilter%20id=%22n%22%20color-interpolation-filters=%22sRGB%22%3E%3CfeTurbulence%20type=%22turbulence%22%20baseFrequency=%222.1%22%20numOctaves=%223%22%20seed=%2211%22%20stitchTiles=%22stitch%22%20result=%22n%22/%3E%3CfeComponentTransfer%20result=%22g%22%3E%3CfeFuncR%20type=%22linear%22%20slope=%225.5%22%20intercept=%221.4%22/%3E%3CfeFuncG%20type=%22linear%22%20slope=%225.5%22%20intercept=%221.4%22/%3E%3CfeFuncB%20type=%22linear%22%20slope=%225.5%22%20intercept=%221.4%22/%3E%3C/feComponentTransfer%3E%3CfeColorMatrix%20type=%22saturate%22%20values=%220%22%20in=%22g%22/%3E%3C/filter%3E%3Crect%20width=%22100%%22%20height=%22100%%22%20filter=%22url(%23n)%22/%3E%3C/svg%3E")`
type Intensity = "fine" | "default" | "rich"
// One scale for every texture; `default` is the unscaled value.
const INTENSITY_MULT: Record<Intensity, number> = {
fine: 0.6,
default: 1,
rich: 1.45,
}
const alpha = (base: number, mult: number) => (base * mult).toFixed(4)
// Four grain treatments; each paints a single texture layer.
// Full-bleed art layer — drop inside a `relative` parent; sits behind content.
/** The texture treatment painted by `Grain`. */
type GrainVariant =
// Stylized paper-look variants — heavier filter chain than plain noise.
"paper" | "sandpaper" | "square" | "single"
type Layer = {
src: string
size: string
opacity: number
blend: "overlay" | "soft-light"
}
const BLEND_CLASS: Record<Layer["blend"], string> = {
overlay: "mix-blend-overlay",
"soft-light": "mix-blend-soft-light",
}
const VARIANT_TEXTURES: Record<GrainVariant, Layer> = {
paper: {
src: PAPER_GRAIN,
size: "250px",
opacity: 0.25,
blend: "overlay",
},
sandpaper: {
src: SANDPAPER_GRAIN,
size: "200px",
opacity: 0.25,
blend: "overlay",
},
square: {
src: SQUARE_GRAIN,
size: "200px",
opacity: 0.8,
blend: "soft-light",
},
single: { src: SINGLE_NOISE, size: "200px", opacity: 0.3, blend: "overlay" },
}
/**
* A decorative grain layer that fills a positioned parent without blocking
* clicks. Choose a texture and adjust its strength with `intensity` or
* `opacity`. `className` and other div props land on the outer layer.
*/
function Grain({
variant = "single",
intensity = "default",
opacity,
isolated = false,
className,
...props
}: React.ComponentProps<"div"> & {
/** The grain treatment: `single` (default), `paper`, `sandpaper` or `square`. */
variant?: GrainVariant
/** Multiplies the texture's opacity: `fine` 0.6×, `default` 1×, `rich` 1.45×. */
intensity?: Intensity
/** The texture opacity, from 0 to 1. Takes precedence over `intensity`. */
opacity?: number
/**
* Adds paint containment when true. This creates a stacking context, so
* the texture stops blending with scene layers outside this element.
*/
isolated?: boolean
}) {
const layer = VARIANT_TEXTURES[variant]
const m =
opacity != null ? opacity / layer.opacity : INTENSITY_MULT[intensity]
return (
<div
data-slot="grain"
data-variant={variant}
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0",
isolated && "contain-[paint]",
className
)}
{...props}
>
<div
className={cn("absolute inset-0", BLEND_CLASS[layer.blend])}
style={{
backgroundImage: layer.src,
backgroundSize: layer.size,
opacity: layer.opacity * m,
}}
/>
</div>
)
}
export { Grain }
import { cn } from "cn"
// Colored feTurbulence speckle; the top layer blends at `screen`, which
// reads as silver-halide sparkle rather than surface texture.
const WHITE_COARSE = `url("data:image/svg+xml,%3Csvg viewBox='0 0 800 800' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='vg1'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='3.5' numOctaves='10' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23vg1)' fill='white'/%3E%3C/svg%3E")`
const WHITE_FINE = `url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='vg2'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='5.5' numOctaves='8' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23vg2)' fill='white'/%3E%3C/svg%3E")`
const WHITE_MICRO = `url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='vg3'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='7.0' numOctaves='6' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23vg3)' fill='white'/%3E%3C/svg%3E")`
const LAYERS = [
{
src: WHITE_COARSE,
size: "600px 600px",
opacity: 0.8,
blend: "mix-blend-overlay",
},
{
src: WHITE_FINE,
size: "300px 300px",
opacity: 0.7,
blend: "mix-blend-soft-light",
},
{
src: WHITE_MICRO,
size: "150px 150px",
opacity: 0.5,
blend: "mix-blend-screen",
},
]
/**
* Colored film-grain speckle in layers, laid over the art in a full-bleed,
* click-through layer. It is decorative and hidden from assistive tech.
*/
function VibrantGrain({
strength = 1,
className,
...props
}: React.ComponentProps<"div"> & {
/**
* Scales every layer together; 1 is the tuned setting. Above ~1.25 the top
* layer clamps at opacity 1 while the others keep climbing, which inverts
* the balance the stack was tuned for.
*/
strength?: number
}) {
return (
<div
data-slot="vibrant-grain"
aria-hidden="true"
className={cn("pointer-events-none absolute inset-0", className)}
{...props}
>
{LAYERS.map((layer, i) => (
<div
key={i}
className={cn("absolute inset-0", layer.blend)}
style={{
backgroundImage: layer.src,
backgroundSize: layer.size,
opacity: Math.min(1, layer.opacity * strength),
}}
/>
))}
</div>
)
}
export { VibrantGrain }
pnpm dlx shadcn@latest add @01orbital/vibrant-grain-announcement-pillnpx shadcn@latest add @01orbital/vibrant-grain-announcement-pillyarn dlx shadcn@latest add @01orbital/vibrant-grain-announcement-pillbunx --bun shadcn@latest add @01orbital/vibrant-grain-announcement-pill· Launch bannervibrant-grain-launch-banner
Vibrant Grain texture example: a launch banner on a warm brown ground under both grains, with a headline, copy, a link and three swatches showing each grain alone and the two stacked. Use it to announce a product.
import { ArrowRightIcon } from "@phosphor-icons/react/ssr"
import { cn } from "cn"
import { Grain } from "@/components/texture/grain"
import { VibrantGrain } from "@/components/texture/vibrant-grain"
import { buttonVariants } from "@/components/ui/button"
// The copy: change text here, not in the markup.
const COPY = {
label: "Grain, stacked",
title: "Tone under. Light on top.",
description:
"The tonal grain settles into the surface; the speckle sits on it as light. Together they read as a print.",
action: "Get the grain",
} as const
const SWATCHES = [
{ label: "tonal", grain: true, speckle: 0 },
{ label: "speckle", grain: false, speckle: 0.5 },
{ label: "both", grain: true, speckle: 0.4 },
] as const
/** A launch banner on a warm ground under both grains, with three swatches showing each grain alone and the two stacked. */
export default function VibrantGrainLaunchBanner() {
return (
<div className="relative isolate w-full overflow-hidden rounded-2xl text-[#f3e9dd]">
<div
aria-hidden="true"
className="pointer-events-none absolute inset-0 bg-[linear-gradient(135deg,#1a1512_0%,#2d2018_40%,#3a2a1d_70%,#4a3525_100%)] contain-[paint]"
>
<Grain variant="single" />
<VibrantGrain strength={0.4} />
</div>
<div className="relative grid gap-8 p-8 sm:p-12 lg:grid-cols-[1fr_auto] lg:items-center">
<div className="flex max-w-lg flex-col gap-4">
<p className="font-mono text-xs tracking-[0.18em] text-[#e9ddcf] uppercase">
{COPY.label}
</p>
<h2 className="text-5xl/[1.05] font-medium tracking-tight">
{COPY.title}
</h2>
<p className="max-w-sm text-base/7 text-[#e9ddcf]">
{COPY.description}
</p>
<div>
<a
href="#"
className={cn(
buttonVariants(),
"h-11 bg-[#f3e9dd] px-5 text-[#1a1512] hover:bg-white"
)}
>
{COPY.action} <ArrowRightIcon />
</a>
</div>
</div>
<div aria-hidden="true" className="grid grid-cols-3 gap-3">
{SWATCHES.map((swatch) => (
<div key={swatch.label} className="flex flex-col gap-2">
<div className="relative size-24 overflow-hidden rounded-xl bg-[linear-gradient(135deg,#1a1512_0%,#2d2018_40%,#3a2a1d_70%,#4a3525_100%)] ring-1 ring-[#f3e9dd]/15 contain-[paint] sm:size-28">
{swatch.grain ? <Grain variant="single" /> : null}
{swatch.speckle ? (
<VibrantGrain strength={swatch.speckle} />
) : null}
</div>
<span className="font-mono text-xs text-[#e9ddcf]">
{swatch.label}
</span>
</div>
))}
</div>
</div>
</div>
)
}
import { cn } from "cn"
// Paper grain: an SVG turbulence filter as a data URI.
const PAPER_GRAIN = `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='250' height='250' viewBox='0 0 100 100'%3E%3Cfilter id='n' color-interpolation-filters='sRGB'%3E%3CfeTurbulence type='turbulence' baseFrequency='1.4' numOctaves='1' seed='2' stitchTiles='stitch' result='n'/%3E%3CfeComponentTransfer result='g'%3E%3CfeFuncR type='linear' slope='4' intercept='1'/%3E%3CfeFuncG type='linear' slope='4' intercept='1'/%3E%3CfeFuncB type='linear' slope='4' intercept='1'/%3E%3C/feComponentTransfer%3E%3CfeColorMatrix type='saturate' values='0' in='g'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")`
// Sandpaper grain: an SVG turbulence filter as a data URI.
const SANDPAPER_GRAIN = `url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200' viewBox='0 0 100 100'%3E%3Cfilter id='n' color-interpolation-filters='sRGB'%3E%3CfeTurbulence type='turbulence' baseFrequency='2.2' numOctaves='2' seed='5' stitchTiles='stitch' result='n'/%3E%3CfeComponentTransfer result='g'%3E%3CfeFuncR type='linear' slope='2.5' intercept='0.8'/%3E%3CfeFuncG type='linear' slope='2.5' intercept='0.8'/%3E%3CfeFuncB type='linear' slope='2.5' intercept='0.8'/%3E%3C/feComponentTransfer%3E%3CfeColorMatrix type='saturate' values='0' in='g'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")`
// Single noise: an SVG turbulence filter as a data URI.
const SINGLE_NOISE = `url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n' color-interpolation-filters='sRGB'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")`
// Square grain: an SVG turbulence filter as a data URI.
const SQUARE_GRAIN = `url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20width=%22200%22%20height=%22200%22%20viewBox=%220%200%20100%20100%22%3E%3Cfilter%20id=%22n%22%20color-interpolation-filters=%22sRGB%22%3E%3CfeTurbulence%20type=%22turbulence%22%20baseFrequency=%222.1%22%20numOctaves=%223%22%20seed=%2211%22%20stitchTiles=%22stitch%22%20result=%22n%22/%3E%3CfeComponentTransfer%20result=%22g%22%3E%3CfeFuncR%20type=%22linear%22%20slope=%225.5%22%20intercept=%221.4%22/%3E%3CfeFuncG%20type=%22linear%22%20slope=%225.5%22%20intercept=%221.4%22/%3E%3CfeFuncB%20type=%22linear%22%20slope=%225.5%22%20intercept=%221.4%22/%3E%3C/feComponentTransfer%3E%3CfeColorMatrix%20type=%22saturate%22%20values=%220%22%20in=%22g%22/%3E%3C/filter%3E%3Crect%20width=%22100%%22%20height=%22100%%22%20filter=%22url(%23n)%22/%3E%3C/svg%3E")`
type Intensity = "fine" | "default" | "rich"
// One scale for every texture; `default` is the unscaled value.
const INTENSITY_MULT: Record<Intensity, number> = {
fine: 0.6,
default: 1,
rich: 1.45,
}
const alpha = (base: number, mult: number) => (base * mult).toFixed(4)
// Four grain treatments; each paints a single texture layer.
// Full-bleed art layer — drop inside a `relative` parent; sits behind content.
/** The texture treatment painted by `Grain`. */
type GrainVariant =
// Stylized paper-look variants — heavier filter chain than plain noise.
"paper" | "sandpaper" | "square" | "single"
type Layer = {
src: string
size: string
opacity: number
blend: "overlay" | "soft-light"
}
const BLEND_CLASS: Record<Layer["blend"], string> = {
overlay: "mix-blend-overlay",
"soft-light": "mix-blend-soft-light",
}
const VARIANT_TEXTURES: Record<GrainVariant, Layer> = {
paper: {
src: PAPER_GRAIN,
size: "250px",
opacity: 0.25,
blend: "overlay",
},
sandpaper: {
src: SANDPAPER_GRAIN,
size: "200px",
opacity: 0.25,
blend: "overlay",
},
square: {
src: SQUARE_GRAIN,
size: "200px",
opacity: 0.8,
blend: "soft-light",
},
single: { src: SINGLE_NOISE, size: "200px", opacity: 0.3, blend: "overlay" },
}
/**
* A decorative grain layer that fills a positioned parent without blocking
* clicks. Choose a texture and adjust its strength with `intensity` or
* `opacity`. `className` and other div props land on the outer layer.
*/
function Grain({
variant = "single",
intensity = "default",
opacity,
isolated = false,
className,
...props
}: React.ComponentProps<"div"> & {
/** The grain treatment: `single` (default), `paper`, `sandpaper` or `square`. */
variant?: GrainVariant
/** Multiplies the texture's opacity: `fine` 0.6×, `default` 1×, `rich` 1.45×. */
intensity?: Intensity
/** The texture opacity, from 0 to 1. Takes precedence over `intensity`. */
opacity?: number
/**
* Adds paint containment when true. This creates a stacking context, so
* the texture stops blending with scene layers outside this element.
*/
isolated?: boolean
}) {
const layer = VARIANT_TEXTURES[variant]
const m =
opacity != null ? opacity / layer.opacity : INTENSITY_MULT[intensity]
return (
<div
data-slot="grain"
data-variant={variant}
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0",
isolated && "contain-[paint]",
className
)}
{...props}
>
<div
className={cn("absolute inset-0", BLEND_CLASS[layer.blend])}
style={{
backgroundImage: layer.src,
backgroundSize: layer.size,
opacity: layer.opacity * m,
}}
/>
</div>
)
}
export { Grain }
import { cn } from "cn"
// Colored feTurbulence speckle; the top layer blends at `screen`, which
// reads as silver-halide sparkle rather than surface texture.
const WHITE_COARSE = `url("data:image/svg+xml,%3Csvg viewBox='0 0 800 800' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='vg1'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='3.5' numOctaves='10' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23vg1)' fill='white'/%3E%3C/svg%3E")`
const WHITE_FINE = `url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='vg2'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='5.5' numOctaves='8' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23vg2)' fill='white'/%3E%3C/svg%3E")`
const WHITE_MICRO = `url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='vg3'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='7.0' numOctaves='6' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23vg3)' fill='white'/%3E%3C/svg%3E")`
const LAYERS = [
{
src: WHITE_COARSE,
size: "600px 600px",
opacity: 0.8,
blend: "mix-blend-overlay",
},
{
src: WHITE_FINE,
size: "300px 300px",
opacity: 0.7,
blend: "mix-blend-soft-light",
},
{
src: WHITE_MICRO,
size: "150px 150px",
opacity: 0.5,
blend: "mix-blend-screen",
},
]
/**
* Colored film-grain speckle in layers, laid over the art in a full-bleed,
* click-through layer. It is decorative and hidden from assistive tech.
*/
function VibrantGrain({
strength = 1,
className,
...props
}: React.ComponentProps<"div"> & {
/**
* Scales every layer together; 1 is the tuned setting. Above ~1.25 the top
* layer clamps at opacity 1 while the others keep climbing, which inverts
* the balance the stack was tuned for.
*/
strength?: number
}) {
return (
<div
data-slot="vibrant-grain"
aria-hidden="true"
className={cn("pointer-events-none absolute inset-0", className)}
{...props}
>
{LAYERS.map((layer, i) => (
<div
key={i}
className={cn("absolute inset-0", layer.blend)}
style={{
backgroundImage: layer.src,
backgroundSize: layer.size,
opacity: Math.min(1, layer.opacity * strength),
}}
/>
))}
</div>
)
}
export { VibrantGrain }
pnpm dlx shadcn@latest add @01orbital/vibrant-grain-launch-bannernpx shadcn@latest add @01orbital/vibrant-grain-launch-banneryarn dlx shadcn@latest add @01orbital/vibrant-grain-launch-bannerbunx --bun shadcn@latest add @01orbital/vibrant-grain-launch-banner· Sale bannervibrant-grain-sale-banner
Vibrant Grain texture example: a sale banner on a warm brown ground under a strong white speckle, with a large discount figure, two lines of copy and a link. Use it for a limited offer.
import { cn } from "cn"
import { VibrantGrain } from "@/components/texture/vibrant-grain"
import { buttonVariants } from "@/components/ui/button"
// The copy: change text here, not in the markup.
const COPY = {
amount: "30",
label: "Percent off",
detail: "Every grain, this weekend.",
action: "Shop grains",
} as const
/** A sale banner on a warm ground under a strong white speckle. */
export default function VibrantGrainSaleBanner() {
return (
<div className="relative isolate w-full overflow-hidden rounded-2xl text-[#f3e9dd]">
<div
aria-hidden="true"
className="pointer-events-none absolute inset-0 bg-[linear-gradient(135deg,#1a1512_0%,#2d2018_40%,#3a2a1d_70%,#4a3525_100%)] contain-[paint]"
>
<VibrantGrain strength={0.7} />
</div>
<div className="relative flex flex-col gap-6 p-8 sm:flex-row sm:items-end sm:justify-between sm:p-10">
<div className="flex items-end gap-5">
<p className="font-mono text-7xl/none font-medium tracking-tighter">
{COPY.amount}
</p>
<div className="pb-1">
<p className="font-mono text-xs tracking-[0.18em] text-[#e9ddcf] uppercase">
{COPY.label}
</p>
<p className="mt-1 text-base/7">{COPY.detail}</p>
</div>
</div>
<a
href="#"
className={cn(
buttonVariants(),
"h-11 bg-[#f3e9dd] px-5 text-[#1a1512] hover:bg-white"
)}
>
{COPY.action}
</a>
</div>
</div>
)
}
import { cn } from "cn"
// Colored feTurbulence speckle; the top layer blends at `screen`, which
// reads as silver-halide sparkle rather than surface texture.
const WHITE_COARSE = `url("data:image/svg+xml,%3Csvg viewBox='0 0 800 800' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='vg1'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='3.5' numOctaves='10' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23vg1)' fill='white'/%3E%3C/svg%3E")`
const WHITE_FINE = `url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='vg2'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='5.5' numOctaves='8' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23vg2)' fill='white'/%3E%3C/svg%3E")`
const WHITE_MICRO = `url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='vg3'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='7.0' numOctaves='6' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23vg3)' fill='white'/%3E%3C/svg%3E")`
const LAYERS = [
{
src: WHITE_COARSE,
size: "600px 600px",
opacity: 0.8,
blend: "mix-blend-overlay",
},
{
src: WHITE_FINE,
size: "300px 300px",
opacity: 0.7,
blend: "mix-blend-soft-light",
},
{
src: WHITE_MICRO,
size: "150px 150px",
opacity: 0.5,
blend: "mix-blend-screen",
},
]
/**
* Colored film-grain speckle in layers, laid over the art in a full-bleed,
* click-through layer. It is decorative and hidden from assistive tech.
*/
function VibrantGrain({
strength = 1,
className,
...props
}: React.ComponentProps<"div"> & {
/**
* Scales every layer together; 1 is the tuned setting. Above ~1.25 the top
* layer clamps at opacity 1 while the others keep climbing, which inverts
* the balance the stack was tuned for.
*/
strength?: number
}) {
return (
<div
data-slot="vibrant-grain"
aria-hidden="true"
className={cn("pointer-events-none absolute inset-0", className)}
{...props}
>
{LAYERS.map((layer, i) => (
<div
key={i}
className={cn("absolute inset-0", layer.blend)}
style={{
backgroundImage: layer.src,
backgroundSize: layer.size,
opacity: Math.min(1, layer.opacity * strength),
}}
/>
))}
</div>
)
}
export { VibrantGrain }
pnpm dlx shadcn@latest add @01orbital/vibrant-grain-sale-bannernpx shadcn@latest add @01orbital/vibrant-grain-sale-banneryarn dlx shadcn@latest add @01orbital/vibrant-grain-sale-bannerbunx --bun shadcn@latest add @01orbital/vibrant-grain-sale-banner· Status bannervibrant-grain-status-banner
Vibrant Grain texture example: a one-line status banner on a warm brown ground under a light white speckle, with a status dot, a message and a state label. Use it for a system status line.
import { VibrantGrain } from "@/components/texture/vibrant-grain"
// The copy: change text here, not in the markup.
const COPY = {
status: "All downloads are working.",
detail: "Checked every five minutes.",
label: "Stable",
} as const
/** A one-line status banner on a warm ground under a light white speckle. */
export default function VibrantGrainStatusBanner() {
return (
<div className="relative isolate w-full overflow-hidden rounded-2xl text-[#f3e9dd]">
<div
aria-hidden="true"
className="pointer-events-none absolute inset-0 bg-[linear-gradient(135deg,#1a1512_0%,#2d2018_40%,#3a2a1d_70%,#4a3525_100%)] contain-[paint]"
>
<VibrantGrain strength={0.3} />
</div>
<div className="relative flex items-center gap-4 px-6 py-4">
<span className="size-2.5 shrink-0 rounded-full bg-[#f3e9dd]" />
<p className="flex-1 text-sm/6">
<span className="font-medium">{COPY.status}</span>{" "}
<span className="text-[#e9ddcf]">{COPY.detail}</span>
</p>
<span className="font-mono text-xs tracking-[0.18em] text-[#e9ddcf] uppercase">
{COPY.label}
</span>
</div>
</div>
)
}
import { cn } from "cn"
// Colored feTurbulence speckle; the top layer blends at `screen`, which
// reads as silver-halide sparkle rather than surface texture.
const WHITE_COARSE = `url("data:image/svg+xml,%3Csvg viewBox='0 0 800 800' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='vg1'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='3.5' numOctaves='10' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23vg1)' fill='white'/%3E%3C/svg%3E")`
const WHITE_FINE = `url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='vg2'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='5.5' numOctaves='8' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23vg2)' fill='white'/%3E%3C/svg%3E")`
const WHITE_MICRO = `url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='vg3'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='7.0' numOctaves='6' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23vg3)' fill='white'/%3E%3C/svg%3E")`
const LAYERS = [
{
src: WHITE_COARSE,
size: "600px 600px",
opacity: 0.8,
blend: "mix-blend-overlay",
},
{
src: WHITE_FINE,
size: "300px 300px",
opacity: 0.7,
blend: "mix-blend-soft-light",
},
{
src: WHITE_MICRO,
size: "150px 150px",
opacity: 0.5,
blend: "mix-blend-screen",
},
]
/**
* Colored film-grain speckle in layers, laid over the art in a full-bleed,
* click-through layer. It is decorative and hidden from assistive tech.
*/
function VibrantGrain({
strength = 1,
className,
...props
}: React.ComponentProps<"div"> & {
/**
* Scales every layer together; 1 is the tuned setting. Above ~1.25 the top
* layer clamps at opacity 1 while the others keep climbing, which inverts
* the balance the stack was tuned for.
*/
strength?: number
}) {
return (
<div
data-slot="vibrant-grain"
aria-hidden="true"
className={cn("pointer-events-none absolute inset-0", className)}
{...props}
>
{LAYERS.map((layer, i) => (
<div
key={i}
className={cn("absolute inset-0", layer.blend)}
style={{
backgroundImage: layer.src,
backgroundSize: layer.size,
opacity: Math.min(1, layer.opacity * strength),
}}
/>
))}
</div>
)
}
export { VibrantGrain }
pnpm dlx shadcn@latest add @01orbital/vibrant-grain-status-bannernpx shadcn@latest add @01orbital/vibrant-grain-status-banneryarn dlx shadcn@latest add @01orbital/vibrant-grain-status-bannerbunx --bun shadcn@latest add @01orbital/vibrant-grain-status-banner· Event bannervibrant-grain-event-banner
Vibrant Grain texture example: a centered event banner on a warm brown ground, with tonal grain under white speckle, a date line, a headline and a link. Use it for a live event.
import { cn } from "cn"
import { Grain } from "@/components/texture/grain"
import { VibrantGrain } from "@/components/texture/vibrant-grain"
import { buttonVariants } from "@/components/ui/button"
// The copy: change text here, not in the markup.
const COPY = {
label: "Thursday · 18:00 UTC",
title: "Live: when a grain is light, not dirt.",
action: "Save a seat",
} as const
/** A centered event banner on a warm ground, with tonal grain under white speckle. */
export default function VibrantGrainEventBanner() {
return (
<div className="relative isolate w-full overflow-hidden rounded-2xl text-[#f3e9dd]">
<div
aria-hidden="true"
className="pointer-events-none absolute inset-0 bg-[linear-gradient(135deg,#1a1512_0%,#2d2018_40%,#3a2a1d_70%,#4a3525_100%)] contain-[paint]"
>
<Grain variant="single" />
<VibrantGrain strength={0.4} />
</div>
<div className="relative flex flex-col items-center gap-4 px-8 py-14 text-center">
<p className="font-mono text-xs tracking-[0.18em] text-[#e9ddcf] uppercase">
{COPY.label}
</p>
<h2 className="max-w-xl text-4xl/tight font-medium tracking-tight">
{COPY.title}
</h2>
<a
href="#"
className={cn(
buttonVariants(),
"h-11 bg-[#f3e9dd] px-5 text-[#1a1512] hover:bg-white"
)}
>
{COPY.action}
</a>
</div>
</div>
)
}
import { cn } from "cn"
// Paper grain: an SVG turbulence filter as a data URI.
const PAPER_GRAIN = `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='250' height='250' viewBox='0 0 100 100'%3E%3Cfilter id='n' color-interpolation-filters='sRGB'%3E%3CfeTurbulence type='turbulence' baseFrequency='1.4' numOctaves='1' seed='2' stitchTiles='stitch' result='n'/%3E%3CfeComponentTransfer result='g'%3E%3CfeFuncR type='linear' slope='4' intercept='1'/%3E%3CfeFuncG type='linear' slope='4' intercept='1'/%3E%3CfeFuncB type='linear' slope='4' intercept='1'/%3E%3C/feComponentTransfer%3E%3CfeColorMatrix type='saturate' values='0' in='g'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")`
// Sandpaper grain: an SVG turbulence filter as a data URI.
const SANDPAPER_GRAIN = `url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200' viewBox='0 0 100 100'%3E%3Cfilter id='n' color-interpolation-filters='sRGB'%3E%3CfeTurbulence type='turbulence' baseFrequency='2.2' numOctaves='2' seed='5' stitchTiles='stitch' result='n'/%3E%3CfeComponentTransfer result='g'%3E%3CfeFuncR type='linear' slope='2.5' intercept='0.8'/%3E%3CfeFuncG type='linear' slope='2.5' intercept='0.8'/%3E%3CfeFuncB type='linear' slope='2.5' intercept='0.8'/%3E%3C/feComponentTransfer%3E%3CfeColorMatrix type='saturate' values='0' in='g'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")`
// Single noise: an SVG turbulence filter as a data URI.
const SINGLE_NOISE = `url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n' color-interpolation-filters='sRGB'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")`
// Square grain: an SVG turbulence filter as a data URI.
const SQUARE_GRAIN = `url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20width=%22200%22%20height=%22200%22%20viewBox=%220%200%20100%20100%22%3E%3Cfilter%20id=%22n%22%20color-interpolation-filters=%22sRGB%22%3E%3CfeTurbulence%20type=%22turbulence%22%20baseFrequency=%222.1%22%20numOctaves=%223%22%20seed=%2211%22%20stitchTiles=%22stitch%22%20result=%22n%22/%3E%3CfeComponentTransfer%20result=%22g%22%3E%3CfeFuncR%20type=%22linear%22%20slope=%225.5%22%20intercept=%221.4%22/%3E%3CfeFuncG%20type=%22linear%22%20slope=%225.5%22%20intercept=%221.4%22/%3E%3CfeFuncB%20type=%22linear%22%20slope=%225.5%22%20intercept=%221.4%22/%3E%3C/feComponentTransfer%3E%3CfeColorMatrix%20type=%22saturate%22%20values=%220%22%20in=%22g%22/%3E%3C/filter%3E%3Crect%20width=%22100%%22%20height=%22100%%22%20filter=%22url(%23n)%22/%3E%3C/svg%3E")`
type Intensity = "fine" | "default" | "rich"
// One scale for every texture; `default` is the unscaled value.
const INTENSITY_MULT: Record<Intensity, number> = {
fine: 0.6,
default: 1,
rich: 1.45,
}
const alpha = (base: number, mult: number) => (base * mult).toFixed(4)
// Four grain treatments; each paints a single texture layer.
// Full-bleed art layer — drop inside a `relative` parent; sits behind content.
/** The texture treatment painted by `Grain`. */
type GrainVariant =
// Stylized paper-look variants — heavier filter chain than plain noise.
"paper" | "sandpaper" | "square" | "single"
type Layer = {
src: string
size: string
opacity: number
blend: "overlay" | "soft-light"
}
const BLEND_CLASS: Record<Layer["blend"], string> = {
overlay: "mix-blend-overlay",
"soft-light": "mix-blend-soft-light",
}
const VARIANT_TEXTURES: Record<GrainVariant, Layer> = {
paper: {
src: PAPER_GRAIN,
size: "250px",
opacity: 0.25,
blend: "overlay",
},
sandpaper: {
src: SANDPAPER_GRAIN,
size: "200px",
opacity: 0.25,
blend: "overlay",
},
square: {
src: SQUARE_GRAIN,
size: "200px",
opacity: 0.8,
blend: "soft-light",
},
single: { src: SINGLE_NOISE, size: "200px", opacity: 0.3, blend: "overlay" },
}
/**
* A decorative grain layer that fills a positioned parent without blocking
* clicks. Choose a texture and adjust its strength with `intensity` or
* `opacity`. `className` and other div props land on the outer layer.
*/
function Grain({
variant = "single",
intensity = "default",
opacity,
isolated = false,
className,
...props
}: React.ComponentProps<"div"> & {
/** The grain treatment: `single` (default), `paper`, `sandpaper` or `square`. */
variant?: GrainVariant
/** Multiplies the texture's opacity: `fine` 0.6×, `default` 1×, `rich` 1.45×. */
intensity?: Intensity
/** The texture opacity, from 0 to 1. Takes precedence over `intensity`. */
opacity?: number
/**
* Adds paint containment when true. This creates a stacking context, so
* the texture stops blending with scene layers outside this element.
*/
isolated?: boolean
}) {
const layer = VARIANT_TEXTURES[variant]
const m =
opacity != null ? opacity / layer.opacity : INTENSITY_MULT[intensity]
return (
<div
data-slot="grain"
data-variant={variant}
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0",
isolated && "contain-[paint]",
className
)}
{...props}
>
<div
className={cn("absolute inset-0", BLEND_CLASS[layer.blend])}
style={{
backgroundImage: layer.src,
backgroundSize: layer.size,
opacity: layer.opacity * m,
}}
/>
</div>
)
}
export { Grain }
import { cn } from "cn"
// Colored feTurbulence speckle; the top layer blends at `screen`, which
// reads as silver-halide sparkle rather than surface texture.
const WHITE_COARSE = `url("data:image/svg+xml,%3Csvg viewBox='0 0 800 800' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='vg1'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='3.5' numOctaves='10' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23vg1)' fill='white'/%3E%3C/svg%3E")`
const WHITE_FINE = `url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='vg2'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='5.5' numOctaves='8' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23vg2)' fill='white'/%3E%3C/svg%3E")`
const WHITE_MICRO = `url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='vg3'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='7.0' numOctaves='6' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23vg3)' fill='white'/%3E%3C/svg%3E")`
const LAYERS = [
{
src: WHITE_COARSE,
size: "600px 600px",
opacity: 0.8,
blend: "mix-blend-overlay",
},
{
src: WHITE_FINE,
size: "300px 300px",
opacity: 0.7,
blend: "mix-blend-soft-light",
},
{
src: WHITE_MICRO,
size: "150px 150px",
opacity: 0.5,
blend: "mix-blend-screen",
},
]
/**
* Colored film-grain speckle in layers, laid over the art in a full-bleed,
* click-through layer. It is decorative and hidden from assistive tech.
*/
function VibrantGrain({
strength = 1,
className,
...props
}: React.ComponentProps<"div"> & {
/**
* Scales every layer together; 1 is the tuned setting. Above ~1.25 the top
* layer clamps at opacity 1 while the others keep climbing, which inverts
* the balance the stack was tuned for.
*/
strength?: number
}) {
return (
<div
data-slot="vibrant-grain"
aria-hidden="true"
className={cn("pointer-events-none absolute inset-0", className)}
{...props}
>
{LAYERS.map((layer, i) => (
<div
key={i}
className={cn("absolute inset-0", layer.blend)}
style={{
backgroundImage: layer.src,
backgroundSize: layer.size,
opacity: Math.min(1, layer.opacity * strength),
}}
/>
))}
</div>
)
}
export { VibrantGrain }
pnpm dlx shadcn@latest add @01orbital/vibrant-grain-event-bannernpx shadcn@latest add @01orbital/vibrant-grain-event-banneryarn dlx shadcn@latest add @01orbital/vibrant-grain-event-bannerbunx --bun shadcn@latest add @01orbital/vibrant-grain-event-banner· Countdown bannervibrant-grain-countdown-banner
Vibrant Grain texture example: a countdown banner on a warm brown ground under white speckle, with a label, a title and three cream counter tiles. Use it ahead of a launch.
import { VibrantGrain } from "@/components/texture/vibrant-grain"
// The copy: change text here, not in the markup.
const COPY = {
label: "Doors open in",
title: "The print drop.",
} as const
const COUNTDOWN = [
{ value: "01", unit: "Day" },
{ value: "18", unit: "Hrs" },
{ value: "05", unit: "Min" },
] as const
/** A countdown banner on a warm ground under white speckle. */
export default function VibrantGrainCountdownBanner() {
return (
<div className="relative isolate w-full overflow-hidden rounded-2xl text-[#f3e9dd]">
<div
aria-hidden="true"
className="pointer-events-none absolute inset-0 bg-[linear-gradient(135deg,#1a1512_0%,#2d2018_40%,#3a2a1d_70%,#4a3525_100%)] contain-[paint]"
>
<VibrantGrain strength={0.5} />
</div>
<div className="relative flex flex-col gap-6 p-8 md:flex-row md:items-center md:justify-between md:p-10">
<div className="flex flex-col gap-2">
<p className="font-mono text-xs tracking-[0.18em] text-[#e9ddcf] uppercase">
{COPY.label}
</p>
<h2 className="text-3xl/tight font-medium tracking-tight">
{COPY.title}
</h2>
</div>
<div className="flex gap-3">
{COUNTDOWN.map((part) => (
<div
key={part.unit}
className="flex w-20 flex-col items-center rounded-xl bg-[#f3e9dd] py-3 text-[#1a1512]"
>
<span className="font-mono text-3xl/none font-medium">
{part.value}
</span>
<span className="mt-1.5 font-mono text-xs tracking-widest uppercase">
{part.unit}
</span>
</div>
))}
</div>
</div>
</div>
)
}
import { cn } from "cn"
// Colored feTurbulence speckle; the top layer blends at `screen`, which
// reads as silver-halide sparkle rather than surface texture.
const WHITE_COARSE = `url("data:image/svg+xml,%3Csvg viewBox='0 0 800 800' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='vg1'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='3.5' numOctaves='10' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23vg1)' fill='white'/%3E%3C/svg%3E")`
const WHITE_FINE = `url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='vg2'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='5.5' numOctaves='8' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23vg2)' fill='white'/%3E%3C/svg%3E")`
const WHITE_MICRO = `url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='vg3'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='7.0' numOctaves='6' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23vg3)' fill='white'/%3E%3C/svg%3E")`
const LAYERS = [
{
src: WHITE_COARSE,
size: "600px 600px",
opacity: 0.8,
blend: "mix-blend-overlay",
},
{
src: WHITE_FINE,
size: "300px 300px",
opacity: 0.7,
blend: "mix-blend-soft-light",
},
{
src: WHITE_MICRO,
size: "150px 150px",
opacity: 0.5,
blend: "mix-blend-screen",
},
]
/**
* Colored film-grain speckle in layers, laid over the art in a full-bleed,
* click-through layer. It is decorative and hidden from assistive tech.
*/
function VibrantGrain({
strength = 1,
className,
...props
}: React.ComponentProps<"div"> & {
/**
* Scales every layer together; 1 is the tuned setting. Above ~1.25 the top
* layer clamps at opacity 1 while the others keep climbing, which inverts
* the balance the stack was tuned for.
*/
strength?: number
}) {
return (
<div
data-slot="vibrant-grain"
aria-hidden="true"
className={cn("pointer-events-none absolute inset-0", className)}
{...props}
>
{LAYERS.map((layer, i) => (
<div
key={i}
className={cn("absolute inset-0", layer.blend)}
style={{
backgroundImage: layer.src,
backgroundSize: layer.size,
opacity: Math.min(1, layer.opacity * strength),
}}
/>
))}
</div>
)
}
export { VibrantGrain }
pnpm dlx shadcn@latest add @01orbital/vibrant-grain-countdown-bannernpx shadcn@latest add @01orbital/vibrant-grain-countdown-banneryarn dlx shadcn@latest add @01orbital/vibrant-grain-countdown-bannerbunx --bun shadcn@latest add @01orbital/vibrant-grain-countdown-banner· Testimonial bannervibrant-grain-testimonial-banner
Vibrant Grain texture example: a customer quotation on a warm brown ground, with tonal grain under white speckle and a credit line. Use it for a testimonial.
import { Grain } from "@/components/texture/grain"
import { VibrantGrain } from "@/components/texture/vibrant-grain"
// The copy: change text here, not in the markup.
const COPY = {
quote:
"“The speckle made our dark hero look printed instead of rendered. Nobody could say why, they just stayed.”",
credit: "Teo Varga · Halfmoon Press",
} as const
/** A testimonial banner on a warm ground, with tonal grain under white speckle. */
export default function VibrantGrainTestimonialBanner() {
return (
<div className="relative isolate w-full overflow-hidden rounded-2xl text-[#f3e9dd]">
<div
aria-hidden="true"
className="pointer-events-none absolute inset-0 bg-[linear-gradient(135deg,#1a1512_0%,#2d2018_40%,#3a2a1d_70%,#4a3525_100%)] contain-[paint]"
>
<Grain variant="single" />
<VibrantGrain strength={0.4} />
</div>
<figure className="relative flex max-w-3xl flex-col gap-5 p-8 sm:p-12">
<blockquote className="text-3xl/tight font-medium tracking-tight text-pretty">
{COPY.quote}
</blockquote>
<figcaption className="text-sm/6 text-[#e9ddcf]">
{COPY.credit}
</figcaption>
</figure>
</div>
)
}
import { cn } from "cn"
// Paper grain: an SVG turbulence filter as a data URI.
const PAPER_GRAIN = `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='250' height='250' viewBox='0 0 100 100'%3E%3Cfilter id='n' color-interpolation-filters='sRGB'%3E%3CfeTurbulence type='turbulence' baseFrequency='1.4' numOctaves='1' seed='2' stitchTiles='stitch' result='n'/%3E%3CfeComponentTransfer result='g'%3E%3CfeFuncR type='linear' slope='4' intercept='1'/%3E%3CfeFuncG type='linear' slope='4' intercept='1'/%3E%3CfeFuncB type='linear' slope='4' intercept='1'/%3E%3C/feComponentTransfer%3E%3CfeColorMatrix type='saturate' values='0' in='g'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")`
// Sandpaper grain: an SVG turbulence filter as a data URI.
const SANDPAPER_GRAIN = `url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200' viewBox='0 0 100 100'%3E%3Cfilter id='n' color-interpolation-filters='sRGB'%3E%3CfeTurbulence type='turbulence' baseFrequency='2.2' numOctaves='2' seed='5' stitchTiles='stitch' result='n'/%3E%3CfeComponentTransfer result='g'%3E%3CfeFuncR type='linear' slope='2.5' intercept='0.8'/%3E%3CfeFuncG type='linear' slope='2.5' intercept='0.8'/%3E%3CfeFuncB type='linear' slope='2.5' intercept='0.8'/%3E%3C/feComponentTransfer%3E%3CfeColorMatrix type='saturate' values='0' in='g'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")`
// Single noise: an SVG turbulence filter as a data URI.
const SINGLE_NOISE = `url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n' color-interpolation-filters='sRGB'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")`
// Square grain: an SVG turbulence filter as a data URI.
const SQUARE_GRAIN = `url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20width=%22200%22%20height=%22200%22%20viewBox=%220%200%20100%20100%22%3E%3Cfilter%20id=%22n%22%20color-interpolation-filters=%22sRGB%22%3E%3CfeTurbulence%20type=%22turbulence%22%20baseFrequency=%222.1%22%20numOctaves=%223%22%20seed=%2211%22%20stitchTiles=%22stitch%22%20result=%22n%22/%3E%3CfeComponentTransfer%20result=%22g%22%3E%3CfeFuncR%20type=%22linear%22%20slope=%225.5%22%20intercept=%221.4%22/%3E%3CfeFuncG%20type=%22linear%22%20slope=%225.5%22%20intercept=%221.4%22/%3E%3CfeFuncB%20type=%22linear%22%20slope=%225.5%22%20intercept=%221.4%22/%3E%3C/feComponentTransfer%3E%3CfeColorMatrix%20type=%22saturate%22%20values=%220%22%20in=%22g%22/%3E%3C/filter%3E%3Crect%20width=%22100%%22%20height=%22100%%22%20filter=%22url(%23n)%22/%3E%3C/svg%3E")`
type Intensity = "fine" | "default" | "rich"
// One scale for every texture; `default` is the unscaled value.
const INTENSITY_MULT: Record<Intensity, number> = {
fine: 0.6,
default: 1,
rich: 1.45,
}
const alpha = (base: number, mult: number) => (base * mult).toFixed(4)
// Four grain treatments; each paints a single texture layer.
// Full-bleed art layer — drop inside a `relative` parent; sits behind content.
/** The texture treatment painted by `Grain`. */
type GrainVariant =
// Stylized paper-look variants — heavier filter chain than plain noise.
"paper" | "sandpaper" | "square" | "single"
type Layer = {
src: string
size: string
opacity: number
blend: "overlay" | "soft-light"
}
const BLEND_CLASS: Record<Layer["blend"], string> = {
overlay: "mix-blend-overlay",
"soft-light": "mix-blend-soft-light",
}
const VARIANT_TEXTURES: Record<GrainVariant, Layer> = {
paper: {
src: PAPER_GRAIN,
size: "250px",
opacity: 0.25,
blend: "overlay",
},
sandpaper: {
src: SANDPAPER_GRAIN,
size: "200px",
opacity: 0.25,
blend: "overlay",
},
square: {
src: SQUARE_GRAIN,
size: "200px",
opacity: 0.8,
blend: "soft-light",
},
single: { src: SINGLE_NOISE, size: "200px", opacity: 0.3, blend: "overlay" },
}
/**
* A decorative grain layer that fills a positioned parent without blocking
* clicks. Choose a texture and adjust its strength with `intensity` or
* `opacity`. `className` and other div props land on the outer layer.
*/
function Grain({
variant = "single",
intensity = "default",
opacity,
isolated = false,
className,
...props
}: React.ComponentProps<"div"> & {
/** The grain treatment: `single` (default), `paper`, `sandpaper` or `square`. */
variant?: GrainVariant
/** Multiplies the texture's opacity: `fine` 0.6×, `default` 1×, `rich` 1.45×. */
intensity?: Intensity
/** The texture opacity, from 0 to 1. Takes precedence over `intensity`. */
opacity?: number
/**
* Adds paint containment when true. This creates a stacking context, so
* the texture stops blending with scene layers outside this element.
*/
isolated?: boolean
}) {
const layer = VARIANT_TEXTURES[variant]
const m =
opacity != null ? opacity / layer.opacity : INTENSITY_MULT[intensity]
return (
<div
data-slot="grain"
data-variant={variant}
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0",
isolated && "contain-[paint]",
className
)}
{...props}
>
<div
className={cn("absolute inset-0", BLEND_CLASS[layer.blend])}
style={{
backgroundImage: layer.src,
backgroundSize: layer.size,
opacity: layer.opacity * m,
}}
/>
</div>
)
}
export { Grain }
import { cn } from "cn"
// Colored feTurbulence speckle; the top layer blends at `screen`, which
// reads as silver-halide sparkle rather than surface texture.
const WHITE_COARSE = `url("data:image/svg+xml,%3Csvg viewBox='0 0 800 800' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='vg1'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='3.5' numOctaves='10' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23vg1)' fill='white'/%3E%3C/svg%3E")`
const WHITE_FINE = `url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='vg2'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='5.5' numOctaves='8' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23vg2)' fill='white'/%3E%3C/svg%3E")`
const WHITE_MICRO = `url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='vg3'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='7.0' numOctaves='6' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23vg3)' fill='white'/%3E%3C/svg%3E")`
const LAYERS = [
{
src: WHITE_COARSE,
size: "600px 600px",
opacity: 0.8,
blend: "mix-blend-overlay",
},
{
src: WHITE_FINE,
size: "300px 300px",
opacity: 0.7,
blend: "mix-blend-soft-light",
},
{
src: WHITE_MICRO,
size: "150px 150px",
opacity: 0.5,
blend: "mix-blend-screen",
},
]
/**
* Colored film-grain speckle in layers, laid over the art in a full-bleed,
* click-through layer. It is decorative and hidden from assistive tech.
*/
function VibrantGrain({
strength = 1,
className,
...props
}: React.ComponentProps<"div"> & {
/**
* Scales every layer together; 1 is the tuned setting. Above ~1.25 the top
* layer clamps at opacity 1 while the others keep climbing, which inverts
* the balance the stack was tuned for.
*/
strength?: number
}) {
return (
<div
data-slot="vibrant-grain"
aria-hidden="true"
className={cn("pointer-events-none absolute inset-0", className)}
{...props}
>
{LAYERS.map((layer, i) => (
<div
key={i}
className={cn("absolute inset-0", layer.blend)}
style={{
backgroundImage: layer.src,
backgroundSize: layer.size,
opacity: Math.min(1, layer.opacity * strength),
}}
/>
))}
</div>
)
}
export { VibrantGrain }
pnpm dlx shadcn@latest add @01orbital/vibrant-grain-testimonial-bannernpx shadcn@latest add @01orbital/vibrant-grain-testimonial-banneryarn dlx shadcn@latest add @01orbital/vibrant-grain-testimonial-bannerbunx --bun shadcn@latest add @01orbital/vibrant-grain-testimonial-banner· Cookie consentvibrant-grain-cookie-consent
Vibrant Grain texture example: a small cookie consent card on a warm brown ground under white speckle, with a title, one line of copy and two buttons. Use it for a consent notice.
"use client"
import { useState } from "react"
import { XIcon } from "@phosphor-icons/react"
import { VibrantGrain } from "@/components/texture/vibrant-grain"
import { Button } from "@/components/ui/button"
// The copy: change text here, not in the markup.
const COPY = {
title: "A quiet cookie.",
description:
"One cookie keeps you signed in. Nothing tracks you across sites.",
accept: "Accept",
needed: "Only needed",
dismiss: "Dismiss",
restore: "Show again",
} as const
/** A cookie consent card on a warm ground under white speckle. */
export default function VibrantGrainCookieConsent() {
const [shown, setShown] = useState(true)
if (!shown) {
return (
<Button variant="outline" onClick={() => setShown(true)}>
{COPY.restore}
</Button>
)
}
return (
<div className="relative isolate w-full max-w-md overflow-hidden rounded-2xl text-[#f3e9dd]">
<div
aria-hidden="true"
className="pointer-events-none absolute inset-0 bg-[linear-gradient(135deg,#1a1512_0%,#2d2018_40%,#3a2a1d_70%,#4a3525_100%)] contain-[paint]"
>
<VibrantGrain strength={0.5} />
</div>
<div className="relative p-6">
<div className="flex items-start justify-between gap-4">
<p className="text-xl/7 font-medium tracking-tight">{COPY.title}</p>
<Button
variant="ghost"
size="icon-sm"
aria-label={COPY.dismiss}
onClick={() => setShown(false)}
className="text-[#f3e9dd] hover:bg-white/10 hover:text-[#f3e9dd]"
>
<XIcon />
</Button>
</div>
<p className="mt-2 text-sm/6 text-[#e9ddcf]">{COPY.description}</p>
<div className="mt-5 flex gap-3">
<Button
onClick={() => setShown(false)}
className="h-11 bg-[#f3e9dd] px-5 text-[#1a1512] hover:bg-white"
>
{COPY.accept}
</Button>
<Button
variant="outline"
onClick={() => setShown(false)}
className="h-11 border-[#f3e9dd]/35 bg-transparent px-5 text-[#f3e9dd] hover:bg-white/10 hover:text-[#f3e9dd]"
>
{COPY.needed}
</Button>
</div>
</div>
</div>
)
}
import { cn } from "cn"
// Colored feTurbulence speckle; the top layer blends at `screen`, which
// reads as silver-halide sparkle rather than surface texture.
const WHITE_COARSE = `url("data:image/svg+xml,%3Csvg viewBox='0 0 800 800' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='vg1'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='3.5' numOctaves='10' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23vg1)' fill='white'/%3E%3C/svg%3E")`
const WHITE_FINE = `url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='vg2'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='5.5' numOctaves='8' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23vg2)' fill='white'/%3E%3C/svg%3E")`
const WHITE_MICRO = `url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='vg3'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='7.0' numOctaves='6' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23vg3)' fill='white'/%3E%3C/svg%3E")`
const LAYERS = [
{
src: WHITE_COARSE,
size: "600px 600px",
opacity: 0.8,
blend: "mix-blend-overlay",
},
{
src: WHITE_FINE,
size: "300px 300px",
opacity: 0.7,
blend: "mix-blend-soft-light",
},
{
src: WHITE_MICRO,
size: "150px 150px",
opacity: 0.5,
blend: "mix-blend-screen",
},
]
/**
* Colored film-grain speckle in layers, laid over the art in a full-bleed,
* click-through layer. It is decorative and hidden from assistive tech.
*/
function VibrantGrain({
strength = 1,
className,
...props
}: React.ComponentProps<"div"> & {
/**
* Scales every layer together; 1 is the tuned setting. Above ~1.25 the top
* layer clamps at opacity 1 while the others keep climbing, which inverts
* the balance the stack was tuned for.
*/
strength?: number
}) {
return (
<div
data-slot="vibrant-grain"
aria-hidden="true"
className={cn("pointer-events-none absolute inset-0", className)}
{...props}
>
{LAYERS.map((layer, i) => (
<div
key={i}
className={cn("absolute inset-0", layer.blend)}
style={{
backgroundImage: layer.src,
backgroundSize: layer.size,
opacity: Math.min(1, layer.opacity * strength),
}}
/>
))}
</div>
)
}
export { VibrantGrain }
pnpm dlx shadcn@latest add @01orbital/vibrant-grain-cookie-consentnpx shadcn@latest add @01orbital/vibrant-grain-cookie-consentyarn dlx shadcn@latest add @01orbital/vibrant-grain-cookie-consentbunx --bun shadcn@latest add @01orbital/vibrant-grain-cookie-consentEmbervibrant-grain-ember
Vibrant Grain Ember: an example of vibrant-grain.
import { Eyebrow } from "@/components/eyebrow/eyebrow"
import { VibrantGrain } from "@/components/texture/vibrant-grain"
// The copy: change text here, not in the markup.
const COPY = {
eyebrow: "Vibrant Grain",
plate: "01 / Ember",
note: "Full-strength sparkle on glowing ember.",
} as const
/** Vibrant Grain at a raised strength over a glowing ember gradient on a dark plate. */
export default function VibrantGrainEmber() {
return (
<div className="dark relative isolate grid min-h-[460px] w-full max-w-[606px] grid-cols-1 content-center gap-7 overflow-hidden rounded-[20px] bg-background p-10 text-foreground max-[600px]:min-h-[420px] max-[600px]:rounded-[14px] max-[600px]:p-[28px_24px]">
<div className="relative z-2 flex w-full flex-wrap justify-between gap-3">
<Eyebrow variant="mono" tone="ink">
{COPY.eyebrow}
</Eyebrow>
<Eyebrow variant="mono" tone="ink">
{COPY.plate}
</Eyebrow>
</div>
<div className="relative z-1 h-[260px] overflow-hidden rounded-xl bg-[radial-gradient(ellipse_at_30%_30%,oklch(0.62_0.17_40),oklch(0.28_0.09_20)_70%)]">
<VibrantGrain strength={1.2} />
</div>
<p className="relative z-2 text-xs/5 text-muted-foreground">
{COPY.note}
</p>
</div>
)
}
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
/**
* default is a quiet 14px line, cased as written; icon puts a 16px icon in
* front of it; mono is a 12px uppercase mono label for spec-sheet designs; caps
* is the same size in a sans face. tone picks the ink: muted (the default) or
* the surrounding text color, for a label over art or on a dark island where
* muted-foreground is too quiet.
*/
const eyebrowVariants = cva("", {
variants: {
/**
* The label style. `default` (the default) is a 14px line at weight 500,
* cased as written. `icon` is the same line with a 16px icon, placed
* first among the children, 12px before the words. `mono` is a 12px
* uppercase mono label at weight 500 with 0.12em letter spacing. `caps`
* is the same label in the sans face, for a brand and series label such
* as "Studio Neri / Clay school". The color comes from `tone`.
*/
variant: {
default: "text-sm/5 font-medium",
icon: "flex items-center gap-3 text-sm/5 font-medium [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
mono: "font-mono text-xs/5 font-medium tracking-[0.12em] uppercase",
caps: "text-xs/5 font-medium tracking-[0.12em] uppercase",
},
/**
* The ink. `muted` (the default) is `muted-foreground`. `ink` leaves the
* color to the surrounding text, for a label over art, on a dark island
* or anywhere the muted grey is too quiet to read.
*/
tone: {
muted: "text-muted-foreground",
ink: "",
},
},
defaultVariants: { variant: "default", tone: "muted" },
})
/**
* A short label set above a heading, such as a section name, rendered as a
* `<p>`. Leave 8px between it and the heading. Pass `render` to use another
* element.
*
* `default` is a 14px line at weight 500, cased as written. `icon` adds a
* 16px icon before the words: put the icon first, with `aria-hidden`. `mono`
* is a 12px uppercase mono label with 0.12em letter spacing; `caps` the same
* in the sans face, for a brand and series name such as "Studio Neri / Clay
* school". `tone="muted"` (the default) sets it in `muted-foreground`;
* `tone="ink"` takes the surrounding text color, for a label over art or on
* a dark island where the grey is too quiet.
*/
function Eyebrow({
className,
variant = "default",
tone = "muted",
render,
...props
}: useRender.ComponentProps<"p"> & VariantProps<typeof eyebrowVariants>) {
return useRender({
defaultTagName: "p",
render,
state: { slot: "eyebrow", variant, tone },
props: mergeProps<"p">(
{ className: cn(eyebrowVariants({ variant, tone }), className) },
props
),
})
}
export { Eyebrow, eyebrowVariants }
import { cn } from "cn"
// Colored feTurbulence speckle; the top layer blends at `screen`, which
// reads as silver-halide sparkle rather than surface texture.
const WHITE_COARSE = `url("data:image/svg+xml,%3Csvg viewBox='0 0 800 800' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='vg1'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='3.5' numOctaves='10' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23vg1)' fill='white'/%3E%3C/svg%3E")`
const WHITE_FINE = `url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='vg2'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='5.5' numOctaves='8' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23vg2)' fill='white'/%3E%3C/svg%3E")`
const WHITE_MICRO = `url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='vg3'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='7.0' numOctaves='6' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23vg3)' fill='white'/%3E%3C/svg%3E")`
const LAYERS = [
{
src: WHITE_COARSE,
size: "600px 600px",
opacity: 0.8,
blend: "mix-blend-overlay",
},
{
src: WHITE_FINE,
size: "300px 300px",
opacity: 0.7,
blend: "mix-blend-soft-light",
},
{
src: WHITE_MICRO,
size: "150px 150px",
opacity: 0.5,
blend: "mix-blend-screen",
},
]
/**
* Colored film-grain speckle in layers, laid over the art in a full-bleed,
* click-through layer. It is decorative and hidden from assistive tech.
*/
function VibrantGrain({
strength = 1,
className,
...props
}: React.ComponentProps<"div"> & {
/**
* Scales every layer together; 1 is the tuned setting. Above ~1.25 the top
* layer clamps at opacity 1 while the others keep climbing, which inverts
* the balance the stack was tuned for.
*/
strength?: number
}) {
return (
<div
data-slot="vibrant-grain"
aria-hidden="true"
className={cn("pointer-events-none absolute inset-0", className)}
{...props}
>
{LAYERS.map((layer, i) => (
<div
key={i}
className={cn("absolute inset-0", layer.blend)}
style={{
backgroundImage: layer.src,
backgroundSize: layer.size,
opacity: Math.min(1, layer.opacity * strength),
}}
/>
))}
</div>
)
}
export { VibrantGrain }
pnpm dlx shadcn@latest add @01orbital/vibrant-grain-embernpx shadcn@latest add @01orbital/vibrant-grain-emberyarn dlx shadcn@latest add @01orbital/vibrant-grain-emberbunx --bun shadcn@latest add @01orbital/vibrant-grain-emberLagoonvibrant-grain-lagoon
Vibrant Grain Lagoon: an example of vibrant-grain.
import { Eyebrow } from "@/components/eyebrow/eyebrow"
import { VibrantGrain } from "@/components/texture/vibrant-grain"
// The copy: change text here, not in the markup.
const COPY = {
eyebrow: "Vibrant Grain",
plate: "02 / Lagoon",
note: "A gentler sparkle over deep teal water.",
} as const
/** Vibrant Grain at a gentler strength over a deep teal gradient on a dark plate. */
export default function VibrantGrainLagoon() {
return (
<div className="dark relative isolate grid min-h-[460px] w-full max-w-[606px] grid-cols-1 content-center gap-7 overflow-hidden rounded-[20px] bg-background p-10 text-foreground max-[600px]:min-h-[420px] max-[600px]:rounded-[14px] max-[600px]:p-[28px_24px]">
<div className="relative z-2 flex w-full flex-wrap justify-between gap-3">
<Eyebrow variant="mono" tone="ink">
{COPY.eyebrow}
</Eyebrow>
<Eyebrow variant="mono" tone="ink">
{COPY.plate}
</Eyebrow>
</div>
<div className="relative z-1 h-[260px] overflow-hidden rounded-xl bg-[linear-gradient(170deg,oklch(0.50_0.10_200),oklch(0.22_0.06_225))]">
<VibrantGrain strength={0.6} />
</div>
<p className="relative z-2 text-xs/5 text-muted-foreground">
{COPY.note}
</p>
</div>
)
}
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
/**
* default is a quiet 14px line, cased as written; icon puts a 16px icon in
* front of it; mono is a 12px uppercase mono label for spec-sheet designs; caps
* is the same size in a sans face. tone picks the ink: muted (the default) or
* the surrounding text color, for a label over art or on a dark island where
* muted-foreground is too quiet.
*/
const eyebrowVariants = cva("", {
variants: {
/**
* The label style. `default` (the default) is a 14px line at weight 500,
* cased as written. `icon` is the same line with a 16px icon, placed
* first among the children, 12px before the words. `mono` is a 12px
* uppercase mono label at weight 500 with 0.12em letter spacing. `caps`
* is the same label in the sans face, for a brand and series label such
* as "Studio Neri / Clay school". The color comes from `tone`.
*/
variant: {
default: "text-sm/5 font-medium",
icon: "flex items-center gap-3 text-sm/5 font-medium [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
mono: "font-mono text-xs/5 font-medium tracking-[0.12em] uppercase",
caps: "text-xs/5 font-medium tracking-[0.12em] uppercase",
},
/**
* The ink. `muted` (the default) is `muted-foreground`. `ink` leaves the
* color to the surrounding text, for a label over art, on a dark island
* or anywhere the muted grey is too quiet to read.
*/
tone: {
muted: "text-muted-foreground",
ink: "",
},
},
defaultVariants: { variant: "default", tone: "muted" },
})
/**
* A short label set above a heading, such as a section name, rendered as a
* `<p>`. Leave 8px between it and the heading. Pass `render` to use another
* element.
*
* `default` is a 14px line at weight 500, cased as written. `icon` adds a
* 16px icon before the words: put the icon first, with `aria-hidden`. `mono`
* is a 12px uppercase mono label with 0.12em letter spacing; `caps` the same
* in the sans face, for a brand and series name such as "Studio Neri / Clay
* school". `tone="muted"` (the default) sets it in `muted-foreground`;
* `tone="ink"` takes the surrounding text color, for a label over art or on
* a dark island where the grey is too quiet.
*/
function Eyebrow({
className,
variant = "default",
tone = "muted",
render,
...props
}: useRender.ComponentProps<"p"> & VariantProps<typeof eyebrowVariants>) {
return useRender({
defaultTagName: "p",
render,
state: { slot: "eyebrow", variant, tone },
props: mergeProps<"p">(
{ className: cn(eyebrowVariants({ variant, tone }), className) },
props
),
})
}
export { Eyebrow, eyebrowVariants }
import { cn } from "cn"
// Colored feTurbulence speckle; the top layer blends at `screen`, which
// reads as silver-halide sparkle rather than surface texture.
const WHITE_COARSE = `url("data:image/svg+xml,%3Csvg viewBox='0 0 800 800' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='vg1'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='3.5' numOctaves='10' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23vg1)' fill='white'/%3E%3C/svg%3E")`
const WHITE_FINE = `url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='vg2'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='5.5' numOctaves='8' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23vg2)' fill='white'/%3E%3C/svg%3E")`
const WHITE_MICRO = `url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='vg3'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='7.0' numOctaves='6' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23vg3)' fill='white'/%3E%3C/svg%3E")`
const LAYERS = [
{
src: WHITE_COARSE,
size: "600px 600px",
opacity: 0.8,
blend: "mix-blend-overlay",
},
{
src: WHITE_FINE,
size: "300px 300px",
opacity: 0.7,
blend: "mix-blend-soft-light",
},
{
src: WHITE_MICRO,
size: "150px 150px",
opacity: 0.5,
blend: "mix-blend-screen",
},
]
/**
* Colored film-grain speckle in layers, laid over the art in a full-bleed,
* click-through layer. It is decorative and hidden from assistive tech.
*/
function VibrantGrain({
strength = 1,
className,
...props
}: React.ComponentProps<"div"> & {
/**
* Scales every layer together; 1 is the tuned setting. Above ~1.25 the top
* layer clamps at opacity 1 while the others keep climbing, which inverts
* the balance the stack was tuned for.
*/
strength?: number
}) {
return (
<div
data-slot="vibrant-grain"
aria-hidden="true"
className={cn("pointer-events-none absolute inset-0", className)}
{...props}
>
{LAYERS.map((layer, i) => (
<div
key={i}
className={cn("absolute inset-0", layer.blend)}
style={{
backgroundImage: layer.src,
backgroundSize: layer.size,
opacity: Math.min(1, layer.opacity * strength),
}}
/>
))}
</div>
)
}
export { VibrantGrain }
pnpm dlx shadcn@latest add @01orbital/vibrant-grain-lagoonnpx shadcn@latest add @01orbital/vibrant-grain-lagoonyarn dlx shadcn@latest add @01orbital/vibrant-grain-lagoonbunx --bun shadcn@latest add @01orbital/vibrant-grain-lagoonAPI reference
Colored film-grain speckle in layers, laid over the art in a full-bleed, click-through layer. It is decorative and hidden from assistive tech.
Prop
Type
It also accepts the HTML attributes of the element it renders.
Dependencies
npm: cn. The CLI installs it for you.
Used in blocks
One block is built with Vibrant Grain.
Last updated on