Skip to content

Grid

Stable

A grid that changes its number of columns to fit the screen.

Also known as grid layout, columns, simple grid

Install with npm install @tattva/ui (setup), or copy the code from the kit in Downloads.

Cards that rearrange

One
Two
Three

One column on phones, two on tablets, three on large screens.

When to use it

Lays items out in columns that change with the screen size: 4 on phones, 8 on tablets and 12 on large screens. Or give a minimum width, and it fits as many items in a row as there is room for.

Made of: Outer box · Columns · Items · Space between

Use it for

  • A page layout with a side rail and a main area.
  • A set of cards that should fill the row and wrap.
  • Content that needs one column on phones and more on large screens.

Not for

  • A row of tags or buttons that should just wrap: use Cluster.
  • A single column of items: use Stack.
  • Comparing options feature by feature: use ComparisonTable.

Do and avoid

Flight to Lisbon
Hotel, 3 nights
Airport taxi
Travel cover
Do. Items stretch to fill each column, so the rows line up.
Flight to Lisbon
Hotel, 3 nights
Airport taxi
Travel cover
Avoid. Fixed widths spill past their columns and run into each other.

Do

  • Set columns for page layout and a minimum width for sets of cards.
  • Use one or two columns on phones.
  • Keep items in reading order.
  • Use the page spacing so gaps change with the screen size.

Avoid

  • Do not move items so they look different from reading order.
  • Do not give items a fixed width.
  • Do not put grids inside grids more than two deep.
  • Do not use 12 columns on a phone.

On a phone

  • Below 840px it uses 4 columns by default, so on a phone each item must span columns or it gets a quarter of the width.
  • With the min prop it fits as many columns as it can, and a single column on a phone if min is wider than half the screen.
  • The gutter is 16px on a phone and grows at 840px.

Seen in products

  • Carbon's grid uses 4, 8 and 16 columns as the screen grows, up to a maximum width.
  • Material 3 screen size classes use 4, 8 and 12 columns.
  • Atlassian lists screen sizes with 2, 6 and 12 columns (seen only in a snippet).

Build your next AI screen with Tattva.

Free and open, with the code. Start in one line.

Get started