Skip to content
Founding Lifetime: every Pro skillfirst 100 members · $169 onceUpgrade
Lookbk
Sign In
Effect guide

Bento grid: how to build one in CSS

A bento grid is a CSS Grid layout where tiles span different numbers of columns and rows, so the page reads like a lunch box of compartments. The starter below is one HTML file you can paste, run and change.

Free skills to start. Pro is $79 a year for every skill, or $9.99 a month for 10. See pricing

What is a bento grid?

A bento grid is a layout of rounded tiles in mixed sizes: one large tile, a few small ones, a wide one, a tall one. Each tile holds one idea, such as a metric, a screenshot or a short quote. It is popular on product landing pages for feature sections because the size of a tile tells the reader how much it matters.

There is no special bento property. It is ordinary CSS Grid: a track list for the columns, a fixed row height, and `span` values on the tiles that should be bigger. In `grid-column`, `span 2` means the item covers two tracks from wherever the browser places it, so you do not have to count lines.

The part that most tutorials skip is auto-placement. By default the browser uses a sparse algorithm that, in the words of MDN, only ever moves forward and never backtracks, so a wide tile that does not fit at the end of a row leaves a hole. Adding `dense` to `grid-auto-flow` makes it fill earlier holes with smaller tiles that come later, and MDN notes this can make items appear out of order. A bento grid with holes looks broken, so you choose between reordering the tiles by hand and using `dense`.

How the effect works

The container is `display: grid` with a fixed number of equal columns, here `repeat(4, 1fr)`, and `grid-auto-rows` set to a fixed height. Fixed rows are what make a tall tile exactly twice the height of a short one. Each tile then asks for its size with `grid-column: span 2` and `grid-row: span 2`.

Tiles also need to adapt to the space they actually get, not to the viewport. The starter makes each tile a query container with `container-type: inline-size`, so an `@container` rule can enlarge the heading when the tile is wide. MDN says `inline-size` applies layout, style and inline-size containment, which means a tile cannot take its width from its own content. The grid supplies the width, which is what you want here.

Order matters for accessibility. The CSS Grid spec says grid placement does not change the order used by speech output or by sequential keyboard navigation. If `dense` moves tile 4 above tile 3 on screen, tab and screen reader order still follow the HTML. Write the HTML in the reading order you want, and use `dense` only when tiles are independent of each other.

  1. 01

    Set the grid and fixed row height

    Use `display: grid`, `grid-template-columns: repeat(4, 1fr)` and `grid-auto-rows` with a fixed length. Add a `gap`.

  2. 02

    Give big tiles a span

    Add `grid-column: span 2` for a wide tile and `grid-row: span 2` for a tall one. Leave the small tiles with no rule.

  3. 03

    Check for holes

    Look for empty cells. Fix them by reordering the HTML, resizing a tile, or setting `grid-auto-flow: row dense`.

  4. 04

    Make tiles respond to their own width

    Set `container-type: inline-size` on each tile and write `@container` rules for the content inside.

  5. 05

    Reduce columns on small screens

    Use a media query to switch to two columns on narrow screens and reset the wide spans that would no longer fit.

HTML

Bento grid with span, dense toggle and container queries

Press the button to switch grid-auto-flow between sparse and dense and watch the empty cell fill. Hover lift is off when reduced motion is requested.

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bento grid</title>
<style>
  * { box-sizing: border-box; }
  body { margin: 0; padding: 24px; background: #0e1015; color: #eef0f5; font: 16px/1.4 system-ui, sans-serif; }
  header { display: flex; align-items: center; justify-content: space-between; max-width: 1000px; margin: 0 auto 16px; }
  h1 { font-size: 1.1rem; margin: 0; }
  button { background: #7c9cff; color: #0e1015; border: 0; border-radius: 8px; padding: 8px 14px; font: inherit; font-weight: 600; cursor: pointer; }
  button:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
  .bento {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: 150px;
    gap: 14px;
    max-width: 1000px;
    margin: 0 auto;
    grid-auto-flow: row;
  }
  .bento.dense { grid-auto-flow: row dense; }
  .tile {
    container-type: inline-size;
    border-radius: 20px;
    padding: 18px;
    background: #1a1e29;
    border: 1px solid #2a3042;
    overflow: hidden;
  }
  .tile h2 { margin: 0 0 4px; font-size: 1rem; }
  .tile p { margin: 0; color: #aab1c5; font-size: .9rem; }
  .tile .n { display: block; font-size: .75rem; color: #7c9cff; margin-bottom: 8px; }
  .w2 { grid-column: span 2; }
  .h2 { grid-row: span 2; }
  .hero { background: linear-gradient(135deg, #2b3a7a, #1a1e29); }
  @container (width > 300px) {
    .tile h2 { font-size: 1.6rem; }
    .tile p { font-size: 1rem; }
  }
  @media (prefers-reduced-motion: no-preference) {
    .tile { transition: transform .2s ease, border-color .2s ease; }
    .tile:hover { transform: translateY(-4px); border-color: #7c9cff; }
  }
  @media (max-width: 640px) {
    .bento { grid-template-columns: repeat(2, 1fr); }
    .w2 { grid-column: span 2; }
  }
</style>
</head>
<body>
<header>
  <h1>Bento grid starter</h1>
  <button id="flow" type="button" aria-pressed="false">grid-auto-flow: row</button>
</header>
<main class="bento" id="grid">
  <section class="tile hero w2 h2"><span class="n">1</span><h2>Big feature</h2><p>2 columns by 2 rows</p></section>
  <section class="tile"><span class="n">2</span><h2>Metric</h2><p>1 by 1</p></section>
  <section class="tile w2"><span class="n">3</span><h2>Wide tile</h2><p>Spans 2 columns, so it cannot sit in the last cell of row 1</p></section>
  <section class="tile"><span class="n">4</span><h2>Small</h2><p>Fills the hole in dense mode</p></section>
  <section class="tile h2"><span class="n">5</span><h2>Tall</h2><p>1 by 2</p></section>
  <section class="tile"><span class="n">6</span><h2>Small</h2><p>1 by 1</p></section>
  <section class="tile w2"><span class="n">7</span><h2>Wide</h2><p>2 by 1</p></section>
</main>
<script>
  var grid = document.getElementById('grid');
  var btn = document.getElementById('flow');
  btn.addEventListener('click', function () {
    var on = grid.classList.toggle('dense');
    btn.setAttribute('aria-pressed', String(on));
    btn.textContent = 'grid-auto-flow: ' + (on ? 'row dense' : 'row');
  });
</script>
</body>
</html>

A starting point written for this page, free to use in your own projects. The skills below build the finished version with checks, fallbacks and a recorded video.

What to get right on a real page

  1. 01

    Count the cells before you ship

    Add up the column spans in each row. If a row does not reach the column count, you get a hole in sparse mode. Reorder tiles or change a span until the rows close.

  2. 02

    Keep the HTML in reading order

    The CSS Grid spec says grid placement does not change speech or keyboard order. With `dense`, a tile can look earlier than it is. Use it only when tiles do not depend on each other.

  3. 03

    Use fixed row heights for exact ratios

    A fixed `grid-auto-rows` makes a `span 2` tile exactly two rows plus one gap. Content-sized rows break that, so let tiles scroll or clip inside instead.

  4. 04

    Query the tile, not the viewport

    A tile that spans two columns is wide on a laptop and may be narrow on a phone. A container query on the tile reacts to the width it really has.

  5. 05

    Do not use auto-fit to make bento

    `repeat(auto-fit, minmax(...))` changes the column count with the container, and MDN says only one auto-repeat is allowed per track list. Spans then land on different columns at each width. Fix the count and change it at breakpoints.

  6. 06

    Stop spans that exceed the columns

    At two columns, a tile with `span 3` creates extra implicit columns. Reset spans in the narrow media query.

Skills that build a bento grid

The starter gives you the layout. A finished page also needs real copy, charts, contrast and checks at every width.

  1. Bento SaaS Landing: an example of what it makes
    web
    Bento SaaS LandingClaude CodeCodexCursor+3 more agents

    Landing Pages · Pro

    Bento SaaS Landing

    HTML page or Next.js component · 10 tile types

    It builds a SaaS landing page with a bento-grid feature section, dark or light, from facts about your product. The grid has 6 columns and 160 px rows on desktop, and each tile takes 2, 3, 4 or 6 columns and 1 to 3 rows. A checker then loads the page in headless Chrome at 390, 768, 1024 and 1440 px wide and reports cut-off text, sideways scrolling and low contrast.

    Worth knowing: Every row must add up to 6 columns; the build refuses a grid with gaps. The page also loads Google Fonts when opened, and falls back to the system font without internet access.

    Needs: Node.js 18+, and Chrome for the checks

    See what Bento SaaS Landing makes

Install

Build a bento grid with your agent

Each skill is a SKILL.md folder, so it installs the same way in Claude Code, Codex, Cursor and other agents. The example below uses Bento SaaS Landing; each skill page has its own prompt.

1. Paste the install prompt

Your agent runs the installer. The first time, it shows a sign-in link so you can approve it in the browser.

Install the "Bento SaaS Landing" skill from Lookbk (https://lookbk.dev/skills/bento-saas-landing).
1. Run: curl -fsSL https://lookbk.dev/cli.js | node - add bento-saas-landing
2. If it prints a sign-in link, show it to me. When I say I approved it, run the same command again.
3. When the install finishes, read the SKILL.md it installed and tell me what you need from me to make the first result.

Or run it in a terminal

curl -fsSL https://lookbk.dev/cli.js | node - add bento-saas-landing

2. Start a new session

Agents load skills when a session starts. The installer writes the folder where your agent looks:

Claude Code
~/.claude/skills/bento-saas-landing
Codex
~/.agents/skills/bento-saas-landing
Cursor
~/.agents/skills/bento-saas-landing

3. Ask for the result

Describe it in plain words, for example:

Build a Bento SaaS landing page for our app from the README and docs, as a Next.js component, one tile per real feature.

Another agent? Install a skill in any agent

FAQ

Questions

Still stuck? The guides cover installing, agents and licensing in more detail.

Read the guides
What is a bento grid?

It is a layout of tiles in different sizes arranged in a tight grid, with one idea per tile. In CSS it is a normal grid whose items use `span` to cover more than one column or row.

Do I need a library to make a bento grid?

No. CSS Grid is enough: `grid-template-columns`, `grid-auto-rows` and `grid-column: span N`. Container queries are optional and handle the content inside each tile.

Why does my bento grid have empty cells?

The default sparse auto-placement only moves forward, so a wide tile that does not fit moves to the next row and leaves a gap. Reorder the tiles, change a span, or set `grid-auto-flow: row dense`.

Does grid-auto-flow dense hurt accessibility?

It can. The CSS Grid spec says grid placement does not change speech or sequential keyboard navigation order, so the screen order and the focus order can differ. Keep the HTML in a sensible reading order and avoid dense when order carries meaning.

How do I make a bento grid responsive?

Keep a fixed column count, reduce it with a media query on small screens, and reset wide spans there. Add `container-type: inline-size` to tiles so their content can adapt to the width they receive.