Playground

Bento grid

A responsive asymmetric grid of cards with column and row spans.

  • Built on native elements
  • 2 parts, named exports
  • Plain divs in source order, so reading and tab order match the visual order on phones and follow the DOM elsewhere.
  • Spans collapse to a single column on narrow screens; nothing depends on colour or motion.
  • Styles in one file: bento-grid.css

Import

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

Not installed yet? Pick a route.

Copies the source and its styles into your project.

npx monoline add bento-grid

Usage

import {BentoCard, BentoGrid} from '@monoline/react';

const tile = (title: string, text: string) => (<><h3 style={{margin: 0, fontWeight: 500}}>{title}</h3><p style={{margin: 'var(--s2) 0 0', color: 'var(--muted)'}}>{text}</p></>);

<BentoGrid>
  <BentoCard colSpan={2} rowSpan={2}>{tile('Tokens first', 'Every colour, space and rule comes from one small set of tokens.')}</BentoCard>
  <BentoCard>{tile('Three themes', 'Warm, dark and midnight.')}</BentoCard>
  <BentoCard>{tile('Four accents', 'One accent at a time.')}</BentoCard>
  <BentoCard colSpan={3}>{tile('Plain CSS core', 'Use the stylesheets alone, or the React layer on top.')}</BentoCard>
</BentoGrid>

Anatomy

Import the parts you need and nest them like this.

import {BentoCard, BentoGrid} from '@monoline/react';

<BentoCard>
  <BentoGrid />
</BentoCard>

Examples

Features

Wide and tall tiles collapse to one column on phones.

Props

BentoCardProps

PropTypeDefaultDescription
colSpan1 | 2 | 31Columns to span once the grid has room for them. Default 1.
rowSpan1 | 21Rows to span. Default 1.

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
.bento-cardbento-grid.css
.bento-col-2bento-grid.css
.bento-col-3bento-grid.css
.bento-gridbento-grid.css
.bento-row-2bento-grid.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
.bento-card {
  border-color: var(--accent);
}

Accessibility

  • Plain divs in source order, so reading and tab order match the visual order on phones and follow the DOM elsewhere.
  • Spans collapse to a single column on narrow screens; nothing depends on colour or motion.