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
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
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
Grid(columns: 3, gap: .lg).stacks {
Card { Card.Body { Text("Design") } }
Card { Card.Body { Text("Build") } }
Card { Card.Body { Text("Ship") } }
}
Props
| Prop | Type | Unset | Meaning |
|---|---|---|---|
columns: | Number | none: one column | How many equal columns ( |
gap: | one of its cases | md | Space between its children, from the theme's spacing scale (
|
align: | one of its cases | stretch (the CSS default) | Where its children sit in their cells, down (
|
justify: | one of its cases | start |
|
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, |
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.