Background Pattern
Put a decorative grid, dot or line pattern behind a section or card.
Patterns behind any section
Nine CSS patterns with sizes, fades and tones.
This example installs with a Siteplane UI Pro license key.
Get a license on the Pro page.
pnpm dlx shadcn@4.18.0 add @siteplane-pro/background-pattern-demoThis Pattern is part of Siteplane UI Pro, and its source comes with a Pro license. Its previews are free to view and try.
Installation
pnpm dlx shadcn@4.18.0 add @siteplane-pro/background-patternUsage
import { BackgroundPattern } from "@/siteplane/components/background-pattern";
<BackgroundPattern
pattern="grid"
fade="radial"
className="rounded-2xl px-8 py-16"
>
…
</BackgroundPattern>;Composition
BackgroundPattern
├── pattern layer (hidden from assistive technology)
│ ├── surface
│ ├── pattern with its fade
│ └── grain (optional)
└── childrenBackgroundPattern is a box for your content. Its pattern layer fills the box behind the children, so the content needs no z-index and stays clickable. Without children it is a decorated box; to lay it behind other content, give it absolute inset-0 -z-10 inside a parent with relative isolate.
Patterns
There are nine patterns. dots, grid, stripes, squares and lattice repeat simple marks: dots, lines, rounded squares and 45° diamonds. isometric, cubes and hexagons share one isometric lattice and draw it as triangles, as cubes seen from above and as a honeycomb. siteplane draws the Siteplane UI mark on the same lattice: each mark nests between the two above it, and the slit of its S is a single line. Each pattern is a CSS mask, drawn by a gradient for stripes and by a small inline SVG tile for the others. No image file loads, and the pattern stays sharp on any screen.
This example installs with a Siteplane UI Pro license key.
Get a license on the Pro page.
pnpm dlx shadcn@4.18.0 add @siteplane-pro/background-pattern-patterns-exampleSizes
size sets the cell of the pattern: sm, md (the default) or lg. The cell is the spacing of the dots, stripes and squares, the square of the grid, the width of a lattice diamond, the column of the isometric lattice and the width of a Siteplane UI mark; a cube or a hexagon is two columns wide. Cells are fixed CSS pixels, so a pattern keeps its scale on every screen.
| Pattern | sm | md | lg |
|---|---|---|---|
dots | 12 px | 16 px | 24 px |
grid | 16 px | 24 px | 48 px |
stripes | 6 px | 8 px | 12 px |
squares | 8 px | 12 px | 16 px |
lattice | 48 px | 96 px | 152 px |
isometric | 13 px | 26 px | 52 px |
cubes, hexagons | 13 px | 26 px | 39 px |
siteplane | 72 px | 108 px | 160 px |
This example installs with a Siteplane UI Pro license key.
Get a license on the Pro page.
pnpm dlx shadcn@4.18.0 add @siteplane-pro/background-pattern-sizes-exampleFades
fade lets the pattern settle into the page instead of ending at a hard edge. radial fades it out from the center, edges along all four sides, and top, bottom, start and end toward the side they name. With radial the pattern is faint but not gone at the sides, so use it in a box with a visible edge, such as a card; edges clears all four sides. start and end follow the writing direction, so they mirror in right-to-left layouts.
This example installs with a Siteplane UI Pro license key.
Get a license on the Pro page.
pnpm dlx shadcn@4.18.0 add @siteplane-pro/background-pattern-fades-exampleSurfaces and tones
Without a surface the box is transparent and the pattern sits on the page. surface paints the box: wash is a soft accent gradient that clears toward the top, accent fills it with the accent color, and dark renders the box and its children in the dark theme, on a light page as well. wash and accent follow your theme's accent color.
tone sets the color of the pattern. neutral uses the text color, accent the accent color and contrast white. It is neutral without a surface and contrast on one.
This example installs with a Siteplane UI Pro license key.
Get a license on the Pro page.
pnpm dlx shadcn@4.18.0 add @siteplane-pro/background-pattern-surfaces-and-tones-exampleLine weight
weight="regular" draws lines and dots 1 px wide. weight="hairline" draws them half as wide on 2x and denser screens, which is one device pixel on a 2x display, and a little stronger, so the finer pattern does not fade. On standard screens it stays at 1 px, so compare the two on a high-density display. Filled squares look the same at both weights.
This example installs with a Siteplane UI Pro license key.
Get a license on the Pro page.
pnpm dlx shadcn@4.18.0 add @siteplane-pro/background-pattern-weight-exampleGrain
grain adds a fine noise over the box. On a surface, and on a dark page, it brightens the color in tiny specks, like film grain; on a light page without a surface it scatters faint dark specks instead.
This example installs with a Siteplane UI Pro license key.
Get a license on the Pro page.
pnpm dlx shadcn@4.18.0 add @siteplane-pro/background-pattern-grain-exampleExamples
Stripes on a wash
stripes on surface="wash" with fade="top", behind an install command and a release card.
pnpm dlx shadcn@4.18.0 add @siteplane/card- Release2.4.0
- Changes18
- Checks passed42 of 42
This example installs with a Siteplane UI Pro license key.
Get a license on the Pro page.
pnpm dlx shadcn@4.18.0 add @siteplane-pro/background-pattern-stripes-wash-exampleDots on a dark surface
dots on surface="dark", behind a Command list. The list renders in the dark theme on a light page as well.
This example installs with a Siteplane UI Pro license key.
Get a license on the Pro page.
pnpm dlx shadcn@4.18.0 add @siteplane-pro/background-pattern-dots-dark-exampleSquares in a card
squares with fade="start" inside a subtle Card, behind a Metric Card and a prompt field on a card. rounded-[inherit] rounds the pattern with the outer card.
Deploys this week
This example installs with a Siteplane UI Pro license key.
Get a license on the Pro page.
pnpm dlx shadcn@4.18.0 add @siteplane-pro/background-pattern-squares-chart-exampleLattice on the accent
A large lattice with grain on surface="accent", behind a Settings List on a card.
Notifications
Choose what we email you about.
This example installs with a Siteplane UI Pro license key.
Get a license on the Pro page.
pnpm dlx shadcn@4.18.0 add @siteplane-pro/background-pattern-lattice-accent-exampleThe Siteplane UI mark on a wash
siteplane at lg on surface="wash". fade="top" lets the marks fade out toward the top, where the wash turns light, so the heading sits on a clear background.
Interfaces that feel finished
Components, patterns, sections and templates, finished down to the last micro-interaction.
This example installs with a Siteplane UI Pro license key.
Get a license on the Pro page.
pnpm dlx shadcn@4.18.0 add @siteplane-pro/background-pattern-siteplane-exampleAPI reference
| Prop | Type | Default | Description |
|---|---|---|---|
pattern | dots | grid | stripes | squares | lattice | isometric | cubes | hexagons | siteplane | required | The pattern to draw. |
size | sm | md | lg | md | Cell of the pattern: the spacing of dots, stripes and squares, the grid square, the diamond width, the isometric column or the width of a Siteplane UI mark. |
fade | none | radial | edges | top | bottom | start | end | none | Fades the pattern out from the center, along all four sides or toward one side. start and end follow the writing direction. |
surface | none | wash | accent | dark | none | Paints the box behind the pattern. dark renders the box and its children in the dark theme. |
tone | neutral | accent | contrast | neutral, or contrast on a surface | Color of the pattern: the text color, the accent color or white. |
weight | regular | hairline | regular | regular draws 1 px; hairline draws half as wide on 2x and denser screens. |
grain | boolean | false | Adds a fine grain over the box. |
class | string | unset | Layout of the box, such as its size, radius and padding. |
children | ReactNode | unset | Content shown above the pattern. |
BackgroundPatternProps extends native div props, so id, aria-* and ref reach the box. backgroundPatternNames lists the nine pattern names, and the prop types are exported as BackgroundPatternName, BackgroundPatternSize, BackgroundPatternFade, BackgroundPatternSurface, BackgroundPatternTone and BackgroundPatternWeight.
Usage notes
The pattern is decoration. Its layer is hidden from assistive technology and ignores the pointer, so it needs no text alternative and never blocks a click. Don't let a pattern carry meaning.
Keep text readable. Put patterns behind headings, cards and short copy rather than long text, and fade the pattern out where text sits on it. On the accent and dark surfaces keep the contrast tone; a neutral or accent pattern muddies the color.
Fields are translucent and take the color of what is behind them, so a pattern shows through them; put fields on a card, as in the squares example. On the accent surface, plain text turns white, but components that set their own text color keep it, so put them on a card as well.
surface="dark" switches its children to the dark theme. Siteplane UI components follow it; give your own content theme colors, such as text-muted-foreground, rather than fixed ones.
The box clips its content at its edges and rounded corners. Menus, popovers and tooltips open in a portal outside the box, so it does not clip them, and they keep the theme of the page.
The SVG tiles and the grain are data: URIs that CSS loads as images. If your Content Security Policy limits images through img-src or default-src, allow data: there; otherwise every pattern except stripes stays blank, and so does the grain.