Grid and Dotted Backgrounds for React & shadcn/ui
This DecorativeBackground component provides a seamless way to create grid and dot background patterns.
Though it currently only supports grid and dot patterns, more will be added on demand.
DevRedBox would like to thank Julien Thibeaut for creating such a great guide on crafting grid and dot backgrounds.
Installation
This component uses Tailwind CSS classes for styling and TypeScript support. Make sure you have enabled these in your React project.
This component also uses the cn helper function from shadcn/ui. If you are not using shadcn/ui, follow this guide to create this function.
Paste the following code into your project.
Make sure the import paths match your project's structure.
Props & Usage
Following are the props for DecorativeBackground:
| Prop | Type | Default | Description |
|---|---|---|---|
type | "grid" | "dot" | "grid" | Background pattern type |
options | object | undefined | Styling options for the chosen pattern type |
The rest of the props are defaults for an HTML div element, such as className, id, etc.
The options object differs for dot and grid pattern.
Grid pattern
| Prop | Type | Default | Description |
|---|---|---|---|
spacing | string | string[] | "24px 24px" | The spacing between grid lines |
widths | string[] | ["1px", "1px"] | The widths of the horizontal and vertical grid lines |
colors | string[] | ["#80808012", "#80808012"] | The colors of the horizontal and vertical grid lines |
Dot pattern
| Prop | Type | Default | Description |
|---|---|---|---|
spacing | string | string[] | "16px 16px" | The spacing between dots |
size | string | "1px" | The size of each dot |
color | string | "#1c1c1c" | The color of the dots |
Examples
Dot pattern background.
Grid pattern background with slightly bigger spacing.
A collection of UI components built on shadcn/ui for React and Next.js. Custom shadcn/ui components are also available.
Various pricing cards built with the Cards component of shadcn/ui. Non-shadcn versions are included too.
Last Update: 24 May 2026 at 12:28 PM