Bento grid
A responsive asymmetric grid of cards with column and row spans.
SourceStyles source@monoline/react 0.5.0Markdown for AI toolsstable
- 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
Props
BentoCardProps
| Prop | Type | Default | Description |
|---|---|---|---|
colSpan | 1 | 2 | 3 | 1 | Columns to span once the grid has room for them. Default 1. |
rowSpan | 1 | 2 | 1 | Rows 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
| Class | Stylesheet |
|---|---|
.bento-card | bento-grid.css |
.bento-col-2 | bento-grid.css |
.bento-col-3 | bento-grid.css |
.bento-grid | bento-grid.css |
.bento-row-2 | bento-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.