Playground

Dot pattern

A decorative dot grid background drawn in SVG with currentColor.

  • Built on native elements
  • Decorative: aria-hidden and not focusable, so it adds nothing to the reading order.
  • Static; no motion.
  • Styles in one file: dot-pattern.css

Import

import '@monoline/css';
import {DotPattern} from '@monoline/react';

Not installed yet? Pick a route.

Copies the source and its styles into your project.

npx monoline add dot-pattern

Usage

import {DotPattern} from '@monoline/react';

<div style={{position: 'relative', height: 200, display: 'grid', placeItems: 'center', border: '1px solid var(--rule)'}}>
  <DotPattern fade />
  <span style={{position: 'relative'}}>Content sits above</span>
</div>

Examples

Background

Fills the nearest positioned parent.

Accent, wider gap

Props

DotPatternProps

PropTypeDefaultDescription
gapnumber16Distance between dot centres, in px. Default 16.
radiusnumber1Dot radius, in px. Default 1.
fadeboolean–Fade the pattern out towards the edges.

Data Attributes

State is exposed through attributes. Style it with these selectors, not with class toggles.

This component sets no state attributes.

CSS classes

ClassStylesheet
.dot-patterndot-pattern.css
.dot-pattern-fadedot-pattern.css

Customization

Style it with the kit's tokens in your own CSS, loaded after @monoline/css. Prefer the attributes above over extra classes. See Theming for every token.

app.css
.dot-pattern {
  border-color: var(--accent);
}

Accessibility

  • Decorative: aria-hidden and not focusable, so it adds nothing to the reading order.
  • Static; no motion.