Grid

A responsive, twelve-column layout system built on flexbox. Wrap your content in a Container, group columns in a Row, and size each Col with typed props. Every Bootstrap grid class becomes a prop, so the breakpoints, spans, offsets, and gutters are checked at build time instead of stringed into className.

Import

tsx
import { Container, Row, Col } from '@metatoy/bootstrap-styled';

Equal-width columns

The simplest layout: drop bare Cols into a Row and they share the width evenly. Add as many as you like — the row divides its twelve columns among them.

Setting column widths

Give Col a span of 112 to claim that many of the twelve columns. Use span="auto" to size a column to its content, and a plain Col (or span omitted) to fill whatever space is left.

Responsive columns

Each breakpoint is its own prop — sm, md, lg, xl, xxl — and span is the base (xs, applies from 0 up). A breakpoint prop takes over at that width and larger, so span={12} md={6} xl={4} reads as “full width on phones, halves at md, thirds at xl.”

Offsetting columns

offset (0–11) pushes a column to the right by that many of the twelve columns — handy for centering or leaving a gap. Responsive variants (offsetSmoffsetXxl) shift the offset per breakpoint.

Reordering columns

order controls the visual order independent of the DOM order: 'first', 'last', or a number 05 (plus orderSmorderXxl). Source order stays meaningful for assistive tech while the layout reflows.

Row columns

Instead of sizing every Col, set cols on the Row to say how many equal columns wrap per line — cols={2} colsMd={3} means two across on phones, three from md up. Great for card and tile grids.

Gutters

Gutters are the padding between columns. g sets both axes on the Row (spacing scale 05), while gx and gy set the horizontal and vertical gutter independently. Each has responsive variants (gMd, gxLg, …).

Nesting

Put a Row inside a Col to start a fresh twelve-column track scoped to that column’s width. Nested rows carry their own gutters and can nest as deep as the layout needs.

Containers

Container centers your content and caps its width. By default it steps its max-width at each breakpoint (540, 720, 960, 1140, 1320px). Set fluid for full width at every size, or breakpoint="md" for a container that stays 100% wide until md and is capped above it.

Container props

PropTypeDefaultDescription
fluidboolean`.container-fluid` — full width at every breakpoint.
breakpoint"sm" | "md" | "lg" | "xl" | "xxl"Responsive container: `.container-{sm|md|lg|xl|xxl}` — 100% wide until the chosen breakpoint, then max-width-constrained. Ignored when `fluid`.
asReact.ElementType

Container also accepts all native <div> attributes and an as prop.

Row props

PropTypeDefaultDescription
colsRowColsValue`.row-cols-*` — number of equal-width columns per row (base).
colsSmRowColsValueResponsive `.row-cols-{bp}-*`.
colsMdRowColsValue
colsLgRowColsValue
colsXlRowColsValue
colsXxlRowColsValue
gGutterScale$1`.g-*` — horizontal + vertical gutter (base).
gSmGutterScale$1
gMdGutterScale$1
gLgGutterScale$1
gXlGutterScale$1
gXxlGutterScale$1
gxGutterScale$1`.gx-*` — horizontal gutter only.
gxSmGutterScale$1
gxMdGutterScale$1
gxLgGutterScale$1
gxXlGutterScale$1
gxXxlGutterScale$1
gyGutterScale$1`.gy-*` — vertical gutter only.
gySmGutterScale$1
gyMdGutterScale$1
gyLgGutterScale$1
gyXlGutterScale$1
gyXxlGutterScale$1
asReact.ElementType

Col props

PropTypeDefaultDescription
spanColValueColumn span: 1–12, `'auto'`, or `true` for equal-width (base).
smColValue
mdColValue
lgColValue
xlColValue
xxlColValue
offsetOffsetSpan`.offset-*` — push the column right by N/12 (base).
offsetSmOffsetSpan
offsetMdOffsetSpan
offsetLgOffsetSpan
offsetXlOffsetSpan
offsetXxlOffsetSpan
orderOrderValue`.order-*` — flex order; `'first'` (-1) / `'last'` (6) / 0–5 (base).
orderSmOrderValue
orderMdOrderValue
orderLgOrderValue
orderXlOrderValue
orderXxlOrderValue
asReact.ElementType

Theming

The grid is driven by CSS custom properties rather than fixed values. Row sets --bs-gutter-x (default 1.5rem) and --bs-gutter-y (default 0); the g / gx / gy props write those variables from the spacing scale, and each Col reads them for its side padding and the row’s negative margins. Override --bs-gutter-x / --bs-gutter-y in a scope to reshape spacing globally. Container max-widths follow the five breakpoints (576, 768, 992, 1200, 1400px); see Breakpoints for the full scale.

Accessibility

The grid is purely visual — Container, Row, and Col render plain <div>s with no implied semantics. Keep the DOM order logical (that is what a screen reader and keyboard follow) and reach for order only to adjust the visual arrangement, never to fix a broken reading order. Use the as prop when a grid region should be a landmark such as <main> or <section>.

Explore in Ladle