Grid system
The grid system provides table-based layout components for creating responsive email designs that render reliably across all major clients. It supports both semantic fractions (such as 1/2, 2/3) and fixed/percentage widths, while keeping total content width and spacing consistent.
What it is
The grid is implemented with 2 partials:
columns.html– multi-column rows with automatic width calculation, gutters, per-column alignment, mobile behaviour, and optional “feature” layouts.column.html– a single, full-width content column with optional outlines/borders, rounded corners, and controlled padding.
Both components output email-safe <table> markup.
Examples
No padding
No gutters
No gutters and padding
Three column
Four column
When to use
Use the grid system to:
- Build single-, two-, or multi-column layouts
- Mix fractions, percentages, and fixed pixel widths within the same row when needed
- Create feature layouts (e.g. a hero image/text pair with asymmetric outer padding) using left/right “feature” modes
- Maintain a consistent content width and gutter/padding rhythm across templates
On mobile, columns are output with mobile-12 to stack and span the available width.
Multi-column rows
- Accepts a total row width, outer padding, and gutter; computes the space available for columns and distributes it by fixed/percent/fraction rules
- Supports a rich set of fraction tokens (e.g.
1/2,2/3,3/12) that are resolved to pixel widths, with rounding that preserves the exact total - Calculates the total gutter/outer padding differently when a featurecolumn is pinned to the left or right, so visual edges align cleanly
- Derives the number of columns either from
columnsor from the highest definedcolNWidthprop; falls back to equal fractions if no widths are given - Outputs
<th class="column mobile-12 …" width="…">cells with per-column alignment, bgcolor, mobile class, and optional column separators - Can reverse visual order (useful for RTL or image/text swaps) by emitting
dir="rtl"on the row while keeping logical source order
Single column
- Computes inner width from the page width minus left/right padding, then renders a centred, single-column row.
- Supports outline and individual borders (top/right/bottom/left) with configurable thickness and colour; can also round corners.
- Exposes text alignment, cell alignment, bgcolor, mobile class, and valign.
Props
columns.html
Row-level props
| Prop | Type | Default | Description |
|---|---|---|---|
width | number | page.width (640) | Total row width used for column width calculations. |
padding | number | page.padding | Outer left/right padding for the row (px). |
gutter | number | page.gutter | Space between columns (px). |
bgcolor | string|null | none | Background colour attribute for the row table. |
valign | "top" | "middle" | "bottom" | "top" | Vertical alignment of the row cells. |
mobileClass | string | '' | Default mobile utility class applied to all columns (can be overridden per column). |
feature | "left" | "right" | none | Feature mode adjusts outer padding so the feature column sits flush to the left or right edge. |
borderRight | boolean | false | Adds a vertical divider (right border) between columns, except the last. |
reverse | boolean | false | Reverses visual order (emits dir="rtl") without changing source order. |
columns | number | inferred | Explicit column count. If omitted, inferred from the highest colNWidth provided. |
Per-column props (repeat N starting at 1)
| Prop | Type | Default | Description |
|---|---|---|---|
colNWidth | string | number | 1 / columns | Width for column N. Accepts fraction (e.g. "2/3"), percent (e.g. "33%"), or fixed px (e.g. "300"). |
colNAlign | "left" | "center" | "right" | "left" | Text alignment for column N. |
colNMobileClass | string | mobileClass | Mobile class override for column N. |
colNBgColor | string|null | none | Background colour for column N. |
column.html
| Prop | Type | Default | Description |
|---|---|---|---|
width | number | page.width (640) | Total available width before inner padding. |
padding | number | page.padding | Left/right inner padding for the single column (px). |
bgcolor | string|null | none | Background colour attribute for the row table. |
align | "left" | "center" | "right" | "left" | Horizontal alignment of the inner cell. |
textAlign | "left" | "center" | "right" | "left" | CSS text alignment applied to the column content. |
valign | "top" | "middle" | "bottom" | "top" | Vertical alignment of the row. |
mobileClass | string | '' | Mobile utility class for responsive behaviour. |
outline | boolean | false | Applies an outer border (panel outline) around the column. |
outlineThickness | number | 1 | Outline/border thickness in pixels. |
outlineColor | string | page.grey[200] | Outline/border colour. |
borderTop | boolean | false | Adds a top border instead of a full outline. |
borderRight | boolean | false | Adds a right border instead of a full outline. |
borderBottom | boolean | false | Adds a bottom border instead of a full outline. |
borderLeft | boolean | false | Adds a left border instead of a full outline. |
rounded | boolean | false | Rounds panel corners (and uses separated borders when needed). |
Code examples
Two-column (fractions)
<x-columns columns="2" col1Width="1/3" col2Width="2/3" gutter="16" padding="48">
<slot:col1>
<!-- Left column content -->
</slot:col1>
<slot:col2>
<!-- Right column content -->
</slot:col2>
</x-columns>Fractions are mapped and rounded so totals match precisely.
Three-column (fixed + percent + fraction)
<x-columns columns="3" col1Width="200" col2Width="33%" col3Width="1/3" gutter="16" padding="32" borderRight>
<slot:col1>…</slot:col1>
<slot:col2>…</slot:col2>
<slot:col3>…</slot:col3>
</x-columns>- Mixed width types are supported and resolved in order: fixed, percent, then fractions.
borderRightadds a divider between columns (not the last).
Feature layout (image/text)
<x-columns columns="2" feature="left" col1Width="320" col2Width="1/2" gutter="16" padding="48">
<slot:col1><!-- Feature image --></slot:col1>
<slot:col2><!-- Text content --></slot:col2>
</x-columns>Feature mode adjusts outer padding so the feature column sits flush at the edge.
Single column with outline
<x-column padding="48" outline outlineThickness="2" outlineColor="#cbedfd" textAlign="center" rounded>
<!-- Centered content inside a boxed panel -->
</x-column>Controlled inner padding, optional outline/rounded corners, and text alignment.
Do / Don't
Do
- Use fractions for semantic layouts; switch to fixed orpercentage widths when you need exact sizing
- Keep gutter and outer padding consistent for a clean rhythm
- Use reverse when you need visual order flipped without changing source order
Don't
- Hard-code tables for grids – always use the partials to benefit from consistent calculations and mobile behaviour
- Over-nest rows/columns; keep structures shallow for readability and client robustness
- Mix too many unrelated width schemes in one row unless necessary (readability and quality assurance suffer)