Grid
A grid places its children in evenly-sized columns that shrink, grow, and reflow as the container resizes, without any breakpoints to manage. Drop any number of items into wa-grid and the utility figures out how many fit on each row based on the container's width and the minimum column size you've asked for. It's the quickest way to build card galleries, product listings, dashboards, and any content that should adapt from one column on a phone to several on a desktop.
Set --min-column-size to change the threshold at which items start to wrap, pair wa-grid with a wa-gap-* class to adjust the spacing between cells, or add wa-span-grid to an individual item to make it span every column.
<div class="wa-grid"> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> </div>
Examples
Grids work especially well for card lists and content designed for browsing.
Tulip
Tulipa gesnerianaPeony
Paeonia officinalisPoppy
Papaver rhoeasSunflower
Helianthus annuusDaisy
Bellis perennis<div class="wa-grid"> <div class="wa-stack wa-gap-s"> <div class="wa-frame wa-border-radius-l"> <img src="https://images.unsplash.com/photo-1520763185298-1b434c919102?q=20" alt="" /> </div> <h3 class="wa-heading-m">Tulip</h3> <em>Tulipa gesneriana</em> </div> <div class="wa-stack wa-gap-s"> <div class="wa-frame wa-border-radius-l"> <img src="https://images.unsplash.com/photo-1591767134492-338e62f7b5a2?q=20" alt="" /> </div> <h3 class="wa-heading-m">Peony</h3> <em>Paeonia officinalis</em> </div> <div class="wa-stack wa-gap-s"> <div class="wa-frame wa-border-radius-l"> <img src="https://images.unsplash.com/photo-1590872000386-4348c6393115?q=20" alt="" /> </div> <h3 class="wa-heading-m">Poppy</h3> <em>Papaver rhoeas</em> </div> <div class="wa-stack wa-gap-s"> <div class="wa-frame wa-border-radius-l"> <img src="https://images.unsplash.com/photo-1516723338795-324c7c33f700?q=20" alt="" /> </div> <h3 class="wa-heading-m">Sunflower</h3> <em>Helianthus annuus</em> </div> <div class="wa-stack wa-gap-s"> <div class="wa-frame wa-border-radius-l"> <img src="https://images.unsplash.com/photo-1563601841845-74a0a8ab7c8a?q=20" alt="" /> </div> <h3 class="wa-heading-m">Daisy</h3> <em>Bellis perennis</em> </div> </div>
<div class="wa-grid" style="--min-column-size: 30ch;"> <wa-card> <div class="wa-flank"> <wa-avatar shape="rounded"> <wa-icon slot="icon" name="globe"></wa-icon> </wa-avatar> <div class="wa-stack wa-gap-3xs"> <span class="wa-caption-xs">Population (Zion)</span> <span class="wa-cluster wa-gap-xs"> <span class="wa-heading-2xl">251,999</span> <wa-badge variant="danger">-3% <wa-icon name="arrow-trend-down"></wa-icon></wa-badge> </span> </div> </div> </wa-card> <wa-card> <div class="wa-flank"> <wa-avatar shape="rounded"> <wa-icon slot="icon" name="microchip"></wa-icon> </wa-avatar> <div class="wa-stack wa-gap-3xs"> <span class="wa-caption-xs">Minds Freed</span> <span class="wa-cluster wa-gap-xs"> <span class="wa-heading-2xl">0.36%</span> <wa-badge variant="success">+0.03% <wa-icon name="arrow-trend-up"></wa-icon></wa-badge> </span> </div> </div> </wa-card> <wa-card> <div class="wa-flank"> <wa-avatar shape="rounded"> <wa-icon slot="icon" name="robot"></wa-icon> </wa-avatar> <div class="wa-stack wa-gap-3xs"> <span class="wa-caption-xs">Agents Discovered</span> <span class="wa-cluster wa-gap-xs"> <span class="wa-heading-2xl">3</span> <wa-badge variant="neutral">±0% <wa-icon name="minus"></wa-icon></wa-badge> </span> </div> </div> </wa-card> <wa-card> <div class="wa-flank"> <wa-avatar shape="rounded"> <wa-icon slot="icon" name="spaghetti-monster-flying"></wa-icon> </wa-avatar> <div class="wa-stack wa-gap-3xs"> <span class="wa-caption-xs">Sentinels Controlled</span> <span class="wa-cluster wa-gap-xs"> <span class="wa-heading-2xl">208</span> <wa-badge variant="success">+1% <wa-icon name="arrow-trend-up"></wa-icon></wa-badge> </span> </div> </div> </wa-card> </div> <style> wa-badge > wa-icon { color: color-mix(in oklab, currentColor, transparent 40%); } </style>
Sizing
By default, grid items will wrap when the grid's column size is less than 20ch, but you can set a custom minimum column size using the --min-column-size property.
<div class="wa-stack"> <div class="wa-grid" style="--min-column-size: 200px;"> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> </div> <div class="wa-grid" style="--min-column-size: 6rem;"> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> </div> </div>
Gap
By default, the gap between grid items uses --wa-space-m from your theme. You can add any of the following wa-gap-* classes to an element with wa-grid to specify the gap between items:
wa-gap-0wa-gap-3xswa-gap-2xswa-gap-xswa-gap-swa-gap-mwa-gap-lwa-gap-xlwa-gap-2xlwa-gap-3xl
<div class="wa-stack"> <div class="wa-grid wa-gap-2xs"> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> </div> <div class="wa-grid wa-gap-2xl"> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> </div> </div>
Span Grid
You can add wa-span-grid to any grid item to allow it to span all grid columns. With this, the grid item occupies its own grid row.
<div class="wa-grid"> <div></div> <div></div> <div class="wa-span-grid"></div> <div></div> <div></div> </div>