Skip to Content

Grain Veil

Grain veil texture: noise drawn by one live SVG turbulence filter across the whole box, so it never tiles. Separate light and dark opacities and a theme-following blend; also exports a dither filter for gradient banding.

Installation

pnpm dlx shadcn@latest add @01orbital/grain-veil

Usage

import { SideGlow } from "@/components/glow/side-glow"
import { Subheading } from "@/components/subheading/subheading"
import { GrainVeil } from "@/components/texture/grain-veil"

const COPY = {
  title: "Night notes",
  body: "Written after sundown.",
} as const

export default function GrainVeilDemo() {
  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 />
        <GrainVeil opacity={0.3} />
        <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/grain-veil-demo

Examples

Blushgrain-veil-blush

Grain Veil Blush: an example of grain-veil.

pnpm dlx shadcn@latest add @01orbital/grain-veil-blush

Tealgrain-veil-teal

Grain Veil Teal: an example of grain-veil.

pnpm dlx shadcn@latest add @01orbital/grain-veil-teal

Anatomy

Grain Veil is built from 2 parts. In the example they nest like this:

GrainVeil
  • GrainVeil: A faint, even film grain over the whole box that never repeats. Full-bleed art layer: drop it inside a relative parent; it sits behind content and lets clicks through.
  • DitherFilter: Filter def only: render it, then put filter: url(#id) on your own gradient layer to dither away the banding. The id you pass is the id you reference.

API reference

GrainVeil

A faint, even film grain over the whole box that never repeats. Full-bleed art layer: drop it inside a relative parent; it sits behind content and lets clicks through.

Prop

Type

It also accepts the HTML attributes of the element it renders.

DitherFilter

Filter def only: render it, then put filter: url(#id) on your own gradient layer to dither away the banding. The id you pass is the id you reference.

Prop

Type

Dependencies

npm: cn. The CLI installs it for you.

Used in blocks

7 blocks are built with Grain Veil:

Last updated on