Menu

Bento grid

Added in 1.8.0

A bento grid lays out cards of different sizes, with tiles that span several columns and rows of the same height.

Overview

A bento grid shows cards of different sizes in one block. Some tiles are wide, some are tall, and the edges still line up. Use it for feature sections on landing pages and for dashboard overviews.

The bento grid is built on the CSS grid from Bootstrap. The .grid element has 12 columns, and the .g-col-* classes set how many columns a tile takes. The .grid-bento class adds rows of the same height, and the .g-row-* classes set how many rows a tile takes.

Usage

Add .grid and .grid-bento to the wrapper. Give each card a .g-col-* class for the columns and a .g-row-* class for the rows. A tile without a .g-col-* class takes only one column, so always set the column span.

Two columns wide, two rows tall
Wide tile
Small tile
Small tile
<div class="grid grid-bento">
  <div class="card g-col-6 g-row-2">
    <div class="card-body">Two columns wide, two rows tall</div>
  </div>
  <div class="card g-col-6">
    <div class="card-body">Wide tile</div>
  </div>
  <div class="card g-col-3">
    <div class="card-body">Small tile</div>
  </div>
  <div class="card g-col-3">
    <div class="card-body">Small tile</div>
  </div>
</div>

Responsive tiles

Both classes take a breakpoint, like .g-col-md-6 and .g-row-lg-2. Start with .g-col-12 so every tile is full width on small screens, then set the bento layout from a breakpoint up.

Full width on small screens, a large tile from lg up
Tile
Tile
Wide tile
<div class="grid grid-bento">
  <div class="card g-col-12 g-col-lg-6 g-row-lg-2">
    <div class="card-body">Full width on small screens, a large tile from lg up</div>
  </div>
  <div class="card g-col-12 g-col-md-6 g-col-lg-3">
    <div class="card-body">Tile</div>
  </div>
  <div class="card g-col-12 g-col-md-6 g-col-lg-3">
    <div class="card-body">Tile</div>
  </div>
  <div class="card g-col-12 g-col-lg-6">
    <div class="card-body">Wide tile</div>
  </div>
</div>

Row height

Each row is 10rem high by default. Set --tblr-grid-bento-row-height on the grid to change it. A tile with more content than fits grows taller, and the rest of its row grows with it.

Two rows of 6rem
One row
One row
<div class="grid grid-bento" style="--tblr-grid-bento-row-height: 6rem">
  <div class="card g-col-4 g-row-2">
    <div class="card-body">Two rows of 6rem</div>
  </div>
  <div class="card g-col-8">
    <div class="card-body">One row</div>
  </div>
  <div class="card g-col-8">
    <div class="card-body">One row</div>
  </div>
</div>

Gap and columns

The grid comes with the same --tblr-gap and --tblr-columns variables as .grid. Set --tblr-columns to use fewer columns, so the spans are easier to count.

Two of three columns
Tall tile
Tile
Tile
<div class="grid grid-bento" style="--tblr-columns: 3; --tblr-gap: 0.5rem">
  <div class="card g-col-2">
    <div class="card-body">Two of three columns</div>
  </div>
  <div class="card g-col-1 g-row-2">
    <div class="card-body">Tall tile</div>
  </div>
  <div class="card g-col-1">
    <div class="card-body">Tile</div>
  </div>
  <div class="card g-col-1">
    <div class="card-body">Tile</div>
  </div>
</div>

Accessibility

  • The tiles are read in the order of the markup, not the order on the screen. Put the most important tile first.
  • Do not use .g-start-* to move a tile to a place that changes its meaning. Keyboard and screen reader users still follow the markup.

Class reference

Every class this component ships, grouped by what it changes. A name in braces stands for a family — {color} is any base color, {breakpoint} any responsive step.

grid-bento componentAdded to a .grid element, gives every row the same minimum height
g-start-{n} directionStarts the tile in column n, also with a breakpoint, for example g-start-md-3
g-col-{n} sizeMakes the tile span n of the 12 columns, also with a breakpoint, for example g-col-md-6
g-row-{n} sizeMakes the tile span n rows, from 1 to 4, also with a breakpoint, for example g-row-lg-2

CSS

Variables

The component uses local CSS variables for real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.

On .grid-bento. Source: core/scss/ui/_grid.scss.

--grid-bento-row-height: #{$grid-bento-row-height};

Sass variables

Override these variables before importing Tabler to change the defaults.

Source: core/scss/_variables.scss.

$grid-bento-row-height: 10rem;
$grid-bento-row-spans: 4;