Diagonal Box
Free Background-pattern React component — DiagonalBoxPattern. MIT licensed, copy-paste ready for Next.js and Tailwind CSS.
Classic 45° hairline hatch on white — the same quiet stage used across marketing mockups and component previews.
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
Run in your terminal:
$npm install clsx tailwind-merge lucide-react - 2
Copy
lib/cn.tsbelow. Skip if you already havecn(). - 3
Copy the code below and create
components/background-pattern/diagonal-box-pattern.tsxin your project. - 4
Import and render:
Exampleimport { DiagonalBoxPattern } from "@/components/background-pattern/diagonal-box-pattern";
lib/cn.ts
import { type ClassValue, clsx } from "clsx";import { twMerge } from "tailwind-merge";export function cn(...inputs: ClassValue[]) {return twMerge(clsx(inputs));}
components/background-pattern/diagonal-box-pattern.tsx
import { forwardRef, type HTMLAttributes, type ReactNode } from "react";import { cn } from "@/lib/cn";export interface DiagonalBoxPatternProps extends HTMLAttributes<HTMLDivElement> {children?: ReactNode;}const DiagonalBoxPattern = forwardRef<HTMLDivElement, DiagonalBoxPatternProps>(({ children, className, ...props }, ref) => {return (<divref={ref}data-slot="diagonal-box-pattern"className={cn("relative isolate overflow-hidden bg-white [background-image:repeating-linear-gradient(45deg,#f5f5f5_0,#f5f5f5_1px,transparent_0,transparent_50%)] [background-size:12px_12px]",className,)}{...props}>{children}</div>);},);DiagonalBoxPattern.displayName = "DiagonalBoxPattern";export { DiagonalBoxPattern };