Skip to Content

Simple Grain

Simple grain overlay: a two-octave noise tile at overlay blend with adjustable opacity that follows the parent's corner radius. Built on the grain utility, which comes with the item.

Installation

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

Usage

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

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

export default function SimpleGrainDemo() {
  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 />
        <SimpleGrain />
        <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/simple-grain-demo

Examples

Mistsimple-grain-mist

Simple Grain Mist: an example of simple-grain.

pnpm dlx shadcn@latest add @01orbital/simple-grain-mist

Terracottasimple-grain-terracotta

Simple Grain Terracotta: an example of simple-grain.

pnpm dlx shadcn@latest add @01orbital/simple-grain-terracotta

API reference

Overlay grain from the shared grain texture, laid over its parent and following its rounded corners. The parent needs relative.

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

2 blocks are built with Simple Grain:

Last updated on