Square Grid Background
shadcn-ui-blocks-shadcnship/background-01FreeBlock
Customizable square grid background component with adjustable line color, grid size, and opacity props. Use it as a decorative backdrop for hero sections, cards, or any area that benefits from a subtle geometric texture.
See it running
Open the demo on shadcn-ui-blocks
shadcnship.com/blocks/background-01Install it
npx shadcn@latest add https://shadcnship.com/r/background-01.jsonSource
1import { cn } from "@/lib/utils";23type MaskPosition = "top" | "bottom" | "center" | "none";45type Background01Props = {6 className?: string;7 lineColor?: string;8 gridSizeX?: number;9 gridSizeY?: number;10 mask?: MaskPosition;11};1213const getMaskStyle = (mask: MaskPosition): string => {14 switch (mask) {15 case "top":16 return "radial-gradient(ellipse 60% 50% at 50% 0%, transparent 40%, #000 110%)";17 case "bottom":18 return "radial-gradient(ellipse 60% 50% at 50% 100%, transparent 40%, #000 110%)";19 case "center":20 return "radial-gradient(ellipse 50% 50% at 50% 50%, transparent 20%, #000 70%)";21 case "none":22 default:23 return "none";24 }25};2627const Background01 = ({28 className,29 lineColor = "var(--border)",30 gridSizeX = 20,31 gridSizeY = 20,32 mask = "none",33}: Background01Props) => {34 const maskStyle = getMaskStyle(mask);3536 return (37 <div className={cn("absolute inset-0 z-0 h-full w-full", className)}>38 <div39 className="absolute inset-0 h-full w-full pointer-events-none"40 style={{41 backgroundImage: `linear-gradient(to right, ${lineColor} 1px, transparent 1px), linear-gradient(to bottom, ${lineColor} 1px, transparent 1px)`,42 backgroundSize: `${gridSizeX}px ${gridSizeY}px`,43 ...(mask !== "none" && {44 maskImage: maskStyle,45 WebkitMaskImage: maskStyle,46 }),47 }}48 />49 </div>50 );51};5253export default Background01;
Files it writes
More from shadcn-ui-blocks
All 74 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Dot Pattern Backgroundbackground-02 | shadcn-ui-blocks | Blocks | Free | no deps | |
| Diagonal Stripes Backgroundbackground-03 | shadcn-ui-blocks | Blocks | Free | no deps | |
| Vertical Lines Backgroundbackground-04 | shadcn-ui-blocks | Blocks | Free | no deps | |
| Interactive Grid Backgroundbackground-05 | shadcn-ui-blocks | Blocks | Free | no deps | |
| Banner 01banner-01 | shadcn-ui-blocks | Blocks | Free | 1 dep | |
| Blog 01blog-01 | shadcn-ui-blocks | Blocks | Free | no deps | |
| Changelog 01changelog-01 | shadcn-ui-blocks | Blocks | Free | no deps | |
| Comparison 01comparison-01 | shadcn-ui-blocks | Blocks | Free | 1 dep |
