OpenSourceUIOpenSourceUIOpensource UI
GitHub—
  1. Home
  2. Components
  3. Background-pattern
  4. Fine Grain
Back to Background-patternComponents / Background-pattern

Fine Grain

Free Background-pattern React component — FineGrainPattern. MIT licensed, copy-paste ready for Next.js and Tailwind CSS.

Micro dot grain for a film-paper feel — hero backgrounds that need texture without competing with content.

Preview

Your content

Setup

How to use

Free for personal and commercial use. No UI attribution required. Include the MIT copyright notice when copying component source into your project. Read the MIT license.

  1. 1

    Run in your terminal:

    $npm install clsx tailwind-merge lucide-react
  2. 2

    Copy lib/cn.ts below. Skip if you already have cn().

  3. 3

    Copy the code below and create components/background-pattern/fine-grain-pattern.tsx in your project.

  4. 4

    Import and render:

    Example

    import { FineGrainPattern } from "@/components/background-pattern/fine-grain-pattern";

    <FineGrainPattern className="min-h-screen p-8"><h1>Quiet stage</h1></FineGrainPattern>

lib/cn.ts

1
2
3
4
5
6
import { type ClassValue, clsx } from "clsx";
import { twMerge } from "tailwind-merge";
 
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}

components/background-pattern/fine-grain-pattern.tsx

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { forwardRef, type HTMLAttributes, type ReactNode } from "react";
 
import { cn } from "@/lib/cn";
 
export interface FineGrainPatternProps extends HTMLAttributes<HTMLDivElement> {
children?: ReactNode;
}
 
const FineGrainPattern = forwardRef<HTMLDivElement, FineGrainPatternProps>(
({ children, className, ...props }, ref) => {
return (
<div
ref={ref}
data-slot="fine-grain-pattern"
className={cn(
"relative isolate overflow-hidden bg-[#FAFAFA]",
className,
)}
{...props}
>
<div
aria-hidden="true"
className="pointer-events-none absolute inset-0 -z-10 [background-image:radial-gradient(circle,#d4d4d4_1px,transparent_1px)] [background-size:3px_3px] opacity-55"
/>
 
<div
aria-hidden="true"
className="pointer-events-none absolute inset-0 -z-10 [background-image:radial-gradient(circle,#e5e5e5_1px,transparent_1px)] [background-size:5px_5px] opacity-40"
/>
 
{children}
</div>
);
},
);
 
FineGrainPattern.displayName = "FineGrainPattern";
 
export { FineGrainPattern };
Previous

On this

page

Jump to a section on this page.

  • lib/cn.ts
  • components/background-pattern/fine-grain-pattern.tsx
Platinum slotAvailable

Feature your product here.

Sticky card next to every component — highest-intent placement.

Claim this card