Playground

Grid pattern

A decorative line 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: grid-pattern.css

Import

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

Not installed yet? Pick a route.

Copies the source and its styles into your project.

npx monoline add grid-pattern

Usage

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

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

Examples

Background

Fills the nearest positioned parent.

Accent, larger cells

Props

GridPatternProps

PropTypeDefaultDescription
sizenumber32Cell size in px. Default 32.
fadeboolean–Fade the lines 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
.grid-patterngrid-pattern.css
.grid-pattern-fadegrid-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
.grid-pattern {
  border-color: var(--accent);
}

Accessibility

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