Skip to the content

Layout

pattern

A quiet background of dots, a grid or diagonal lines drawn in the theme's hairline colour, filling the box it sits in, behind the content and hidden from screen readers.

Effects and 3D data

When to use it

A section or a card that needs a texture to set it apart without a colour or a gradient: a hero, an empty state, a canvas. Keep it faint; for a photograph or an illustration use an image.

See it working

The demonstration the browser checks drive, with the keyboard as well as the pointer. More of it is on the Effects and 3D data page.

Word rotate and pattern

Maps for teams, schools, or newsrooms

Animated beam

A map becomes a film.

Orbit

  • Maps
  • Charts
  • Films
  • Motion
Rivier

Confetti

Not yet published.

Point cloud

Ninety finds
#widthheightdepthkind
11.22.52.5Clay
23.22.73.2Stone
32.92.53.8Glass
40.30.64.3Clay
52.71.24.5Stone
642.54.4Glass
70.52.14.1Clay
81.63.13.5Stone
94.13.32.9Glass
101.61.32.1Clay
111.21.21.4Stone
123.11.80.9Glass
132.21.30.6Clay
142.12.70.5Stone
152.23.70.7Glass
161.62.11.2Clay
173.11.81.8Stone
182.61.82.5Glass
190.50.63.2Clay
2031.93.9Stone
213.73.44.3Glass
220.32.54.5Clay
231.92.74.4Stone
244.22.44.1Glass
251.20.63.5Clay
261.21.22.8Stone
273.42.52.1Glass
282.12.21.4Clay
291.73.10.9Stone
302.43.30.6Glass
311.91.20.5Clay
322.81.20.7Stone
332.41.81.2Glass
340.81.41.8Clay
353.12.82.5Stone
363.43.73.2Glass
370.22.13.9Clay
382.31.84.3Stone
394.21.84.5Glass
400.90.64.4Clay
411.324.1Stone
423.83.43.5Glass
4322.52.8Clay
441.52.62.1Stone
452.62.41.4Glass
462.10.60.9Clay
472.51.30.6Stone
482.22.60.5Glass
491.12.20.7Clay
503.23.11.2Stone
5133.21.8Glass
520.21.22.5Clay
532.61.23.3Stone
5441.93.9Glass
550.61.44.3Clay
561.52.84.5Stone
5743.74.4Glass
581.724.1Clay
591.31.73.5Stone
6031.72.8Glass
612.20.72.1Clay
622.221.4Stone
632.23.40.9Glass
641.52.50.6Clay
653.12.60.5Stone
662.72.30.7Glass
670.40.51.2Clay
682.91.31.8Stone
693.82.62.6Glass
700.32.23.3Clay
711.83.13.9Stone
724.23.24.3Glass
731.31.14.5Clay
741.21.14.4Stone
753.31.94.1Glass
762.21.53.5Clay
771.82.92.8Stone
782.33.72.1Glass
791.821.4Clay
802.91.70.9Stone
812.41.70.6Glass
820.70.70.5Clay
833.12.10.7Stone
843.53.51.2Glass
850.22.51.8Clay
862.22.62.6Stone
874.22.33.3Glass
8810.53.9Clay
891.31.34.3Stone
903.72.74.5Glass

Model annotations

  1. Lid — Hinged at the back.
  2. Side — A handle was here.
  3. Front — The maker's mark.

Add it

npx shadcn@latest add @rivier-ui/pattern

The registry is named once in components.json: see Installation.

Example

Import it from @/components/layout/pattern.

<section className="relative overflow-hidden">
  <Pattern variant="grid" />
  <h2 className="relative">Plans</h2>
</section>

What it needs

Plain markup: it can stay a server component. No packages beyond React.

It imports

Source

The whole file. Once copied it is yours: the registry item holds the same text.

src/components/layout/pattern.tsx
/**
 * @name pattern
 * @category layout
 * @description A quiet background of dots, a grid or diagonal lines drawn in the theme's hairline colour, filling the box it sits in, behind the content and hidden from screen readers.
 * @when A section or a card that needs a texture to set it apart without a colour or a gradient: a hero, an empty state, a canvas. Keep it faint; for a photograph or an illustration use an image.
 * @example
 * <section className="relative overflow-hidden">
 *   <Pattern variant="grid" />
 *   <h2 className="relative">Plans</h2>
 * </section>
 */
import { useId, type ComponentProps } from "react";
import { cn } from "@/lib/cn";
 
export type PatternProps = Omit<ComponentProps<"svg">, "children"> & {
  variant?: "dots" | "grid" | "lines";
  /** The distance between marks in pixels. Default 20. */
  size?: number;
};
 
export function Pattern({ variant = "dots", size = 20, className, ...props }: PatternProps) {
  const id = `pattern-${useId().replace(/[^a-zA-Z0-9]/g, "")}`;
  return (
    <svg data-slot="pattern" aria-hidden="true" className={cn("pointer-events-none absolute inset-0 -z-10 size-full", className)} {...props}>
      <defs>
        <pattern id={id} width={size} height={size} patternUnits="userSpaceOnUse">
          {variant === "dots" ? <circle cx={size / 2} cy={size / 2} r={1} className="fill-border-strong" /> : null}
          {variant === "grid" ? <path d={`M${size} 0V${size}H0`} fill="none" className="stroke-border" strokeWidth={1} /> : null}
          {variant === "lines" ? <path d={`M0 ${size}L${size} 0`} fill="none" className="stroke-border" strokeWidth={1} /> : null}
        </pattern>
      </defs>
      <rect width="100%" height="100%" fill={`url(#${id})`} />
    </svg>
  );
}