Skip to content

GkGrid

Layout primitive: display: grid with column counts for mobile, tablet, and desktop breakpoints (mobile-first CSS), tokenized gap, item alignment, optional dashed cell guides, and a configurable root element (for example section).

When to use

Use for multi-column layouts that need three width tiers: below 48rem (mobile), 48rem63.99rem (tablet), and 64rem+ (desktop). Omitted props fall back up the chain (columnsMobilecolumnsTabletcolumns). For simple vertical or horizontal flex rows, use GkStack instead. For max-width page shells, use GkContainer. For data-dense, sortable tables, use GkDataTable.

Live Examples

Two columns

Simple grid with gap and two cells.

Left
Right

Responsive columns and guides

Three columns on wide viewports, one on narrow, with dashed cell outlines.

One
Two
Three

Chrome row

data-gk-grid-chrome marks non-cell rows when show-grid-lines is on.

Preview chrome only
Cell A
Cell B

API

Props

PropTypeDefaultDescription
tagstring'div'Root element (section for landmarks, div for generic wrappers)
columns143Column count from 64rem up (desktop)
columnsTablet14same as columnsColumn count from 48rem to below 64rem
columnsMobile14same as columnsTablet ?? columnsColumn count below 48rem
gap164Spacing token step (maps to --gk-space-*)
showGridLinesbooleanfalseDashed outline on each direct child; omit chrome with data-gk-grid-chrome on a child
alignItems'stretch' | 'start' | 'center' | 'end''stretch'Grid align-items
justifyItems'stretch' | 'start' | 'center' | 'end''stretch'Grid justify-items
textAlign'start' | 'center' | 'end''start'text-align for cell content

Slots

SlotDescription
defaultCell content (any block-level or inline children)

Examples

Each scenario under Live Examples includes a copyable Vue snippet (source is imported from the same SFC as the preview).

Accessibility notes

  • Use tag="section" (or wrap in a sectioning element) when the grid represents a major region; provide a heading inside or aria-label on the section when it has no visible title.
  • Keep DOM order aligned with visual order on all breakpoints; media queries only change grid-template-columns, not content order.
  • For showGridLines, do not rely on outlines alone to convey state; they are a visual aid, not a replacement for clear content structure.

Released under the MIT License.