Reference

Grid

CSS grid with a fixed number of columns.

Grid(columns: Number, gap: Enum, align: Enum, …) { … }

Before 5.0

gap

align

justify

Visitors

12,480

+8%

Sign-ups

342

+3%

Churn

1.2%

-0.4%

Example

wf

Grid(columns: { base: 1, sm: 2, md: 3 }, gap: .md) { Card.elevated { Card.Body { Text("Visitors").muted.sm Heading("12,480").h3 Badge("+8%").success } } Card.elevated { Card.Body { Text("Sign-ups").muted.sm Heading("342").h3 Badge("+3%").success } } Card.elevated { Card.Body { Text("Churn").muted.sm Heading("1.2%").h3 Badge("-0.4%").danger } } }

A fixed number of columns

wf

Grid(columns: 4, gap: .sm) { Badge("A") Badge("B") Badge("C") Badge("D") Badge("E") Badge("F") Badge("G") Badge("H") }

One column on a narrow screen

wf

Grid(columns: 3, gap: .lg).stacks { Card { Card.Body { Text("Design") } } Card { Card.Body { Text("Build") } } Card { Card.Body { Text("Ship") } } }

Props

Props of Grid
PropTypeUnsetMeaning

columns:

Number

none: one column

How many equal columns (repeat(n, 1fr)), a whole 1–12 as a plain number (T01 otherwise); any count in a value per breakpoint, { base: 1, md: 3 }; it follows state

gap:

one of its cases

md

Space between its children, from the theme's spacing scale (wf-gap--*, gap:); a flag (.lg) or a value per breakpoint ({ base: .sm, lg: .lg }). Written as a flag, .xs, or by name, gap: .xs.

  • .xs: Extra small: $spacing-xs, 0.25rem
  • .sm: Small: $spacing-sm, 0.5rem
  • .md (the default): Medium: $spacing-md, 1rem (the default)
  • .lg: Large: $spacing-lg, 1.5rem
  • .xl: Extra large: $spacing-xl, 1.5–2rem, growing with the screen

align:

one of its cases

stretch (the CSS default)

Where its children sit in their cells, down (align-items) (align-items); a flag for .stretch/.baseline, or a value per breakpoint. Written as a flag, .start, or by name, align: .start.

  • .start: align-items: flex-start
  • .center: align-items: center
  • .end: align-items: flex-end
  • .stretch (the default): align-items: stretch: each child fills that axis
  • .baseline: align-items: baseline: text baselines line up

justify:

one of its cases

start

justify-content on the grid's tracks; with its equal 1fr columns the tracks fill the width, so it shows no effect; a flag for .between/.around/.evenly. Written as a flag, .start, or by name, justify: .start.

  • .start (the default): justify-content: flex-start: packed at the start
  • .center: justify-content: center
  • .end: justify-content: flex-end: packed at the end
  • .between: justify-content: space-between: the first and last at the edges
  • .around: justify-content: space-around: equal space around each
  • .evenly: justify-content: space-evenly: equal space everywhere

stacks:

Bool

false

Two columns below 1024px and one below 768px; without it the columns stay as written at every width. Written as a flag, .stacks, or stacks: true.

Attribute families: global, aria, data. Plus the 22 universal props every element takes: animate:, exit:, speed:, duration:, delay:, easing:, stagger:, on:, count:, shared:, class:, ref:, drag:, dragGroup:, dropValue:, dropAxis:, dropInside:, roving:, trapFocus:, mount:, update:, cleanup:.

Flags and cases

A flag is written after the parentheses with a dot: a Bool prop, or a case of one of the element's enum props. A case the enum lacks is an error with a hint.

.xs

.sm

.md

.lg

.xl

.stretch

.baseline

.between

.around

.evenly

.stacks

Events

Every element also takes the props, the events and the attribute families listed on every element.

Slots

children

Renders with the class wf-grid, stable across releases, so a stylesheet may target it.