Textured Image Background
Textured Image Background is a React and Tailwind CSS text component from Cult UI, licensed MIT. Copy it and paste it into your project.
Cult UI
MIT
text
What it is
Textured Image Background is a React and Tailwind CSS text component from Cult UI, licensed MIT. Copy it and paste it into your project.
How to use it
Open it in the catalogue, press copy, and paste it into your project. The prompt you copy carries the code and the rules that tell your agent to reproduce it without changing anything.
Five free copies a month. No card.
No packages beyond the project baseline
Licence
This component comes from Cult UI and is redistributed under the MIT licence, which permits commercial use. The copyright notice travels with the code.
Textured Image Background
import type React from "react"
import { cn } from "@/lib/utils"
export type TextureVariant =
| "fabric-of-squares"
| "grid-noise"
| "inflicted"
| "debut-light"
| "groovepaper"
| "none"
interface BackgroundImageTextureProps {
variant?: TextureVariant
opacity?: number
className?: string
children?: React.ReactNode
}
const textureMap: Record<Exclude<TextureVariant, "none">, string> = {
"fabric-of-squares": "/textures/fabric-of-squares.png",
"grid-noise": "/textures/grid-noise.png",
inflicted: "/textures/inflicted.png",
"debut-light": "/textures/debut-light.png",
groovepaper: "/textures/groovepaper.png",
}
export function BackgroundImageTexture({
variant = "fabric-of-squares",
opacity = 0.5,
className,
children,
}: BackgroundImageTextureProps) {
const textureUrl = variant !== "none" ? textureMap[variant] : null
return (
<div className={cn("relative", className)}>
{textureUrl && (
<div
aria-hidden="true"
className="pointer-events-none absolute inset-0"
style={{
backgroundImage: `url(${textureUrl})`,
backgroundRepeat: "repeat",
opacity,
}}
/>
)}
{children && <div className="relative">{children}</div>}
</div>
)
}