Skip to content

Grid ​

A flexible CSS Grid layout component with element-width responsive columns, named grid areas, and fine-grained item placement. Perfect for dashboards, card grids, photo galleries, and complex page layouts.

Column Layouts ​

Fixed Columns ​

Create grids with a fixed number of columns from 1 to 12.

Full width

Responsive Columns with Breakpoints ​

Use cols-sm, cols-md, cols-lg, cols-xl, and cols-2xl attributes for explicit responsive control.

Full width

Resize to See It Work

Try resizing your browser window or use the viewport controls above to see the grid automatically adapt:

  • Mobile: 1 column
  • Small (≥640px): 2 columns
  • Medium (≥768px): 3 columns
  • Large (≥1024px): 4 columns :::

Breakpoint Reference ​

Breakpoints respond to the element's own width via ResizeObserver, so they work correctly inside sidebars, modals, ComponentPreviews, and any constrained space.

BreakpointAttributeMin Element WidthExample
Mobilecols="1"Default1 column
Smallcols-sm="2"≥640px2 columns
Mediumcols-md="3"≥768px3 columns
Largecols-lg="4"≥1024px4 columns
Extra Largecols-xl="6"≥1280px6 columns
2X Largecols-2xl="8"≥1536px8 columns

Row Layouts ​

Define explicit row counts for dashboard-style layouts.

Full width

Gap Sizes ​

Control spacing between grid items.

Full width

Available Gap Sizes ​

SizeTokenValue
none-0
xs--size-10.25rem (4px)
sm--size-20.5rem (8px)
md--size-41rem (16px)
lg--size-61.5rem (24px)
xl--size-82rem (32px)
2xl--size-123rem (48px)

Flow Control ​

Control how items flow into the grid.

Row Flow (Default) ​

Full width

Column Flow ​

Full width

Dense Packing ​

Automatically fill gaps with smaller items that come later. Avoid flow="row-dense" or flow="column-dense" when reading order matters: items may appear in a different visual order than they exist in the DOM, which can confuse screen reader users and keyboard navigators.

Full width

Dense Packing

With flow="row-dense", item B fills the gap after the first wide item, rather than leaving it empty. This creates a more compact layout but may change visual order.

Dense Packing & Accessibility

When using flow="row-dense" or flow="column-dense", items may appear in a different visual order than they exist in the DOM. This can confuse screen reader users and keyboard navigators. Use dense packing only when layout aesthetics outweigh reading order, or restore meaningful order with tabindex.

Alignment ​

Vertical Alignment (align-items) ​

Full width

Horizontal Alignment (justify-items) ​

Full width

Grid Items ​

Use ore-grid-item for precise placement and span control within a ore-grid.

Named Area Placement ​

When your grid uses areas, assign children with the area attribute instead of inline CSS. This keeps shell and dashboard layouts declarative.

Full width

Column and Row Spans ​

col-span and row-span cover the common case of stretching an item across multiple tracks. Use "full" to span all columns or rows.

Full width

Explicit Placement ​

Use the col and row attributes to set raw CSS grid-column / grid-row values. This accepts any valid CSS shorthand: "2 / 5", "span 3", "1 / -1", etc.

Full width

Item Alignment ​

Use align and justify on ore-grid-item to override the grid's default alignment for a single cell.

Full width

Named Grid Areas ​

Use areas (and its breakpoint variants areas-sm, areas-md, areas-lg, areas-xl, areas-2xl) to define named regions on the grid. The active value is resolved from the element's own width via ResizeObserver, identical to how cols-* breakpoints work. Children can be placed into regions with area="name" on ore-grid-item.

Basic Areas ​

Full width

Responsive Areas ​

Provide different area templates at each breakpoint. The grid switches between them as the element resizes: a single-column stack on small widths, full page layout on larger ones.

Full width

Responsive Auto-fit Mode ​

Use responsive to let the grid fit as many columns as possible based on a minimum column width. Set min-col-width to control the threshold (default: var(--grid-min-item-width), 250px). Do not mix responsive with a fixed cols attribute; they target different layout modes.

Full width

Auto-fit vs Fixed Columns

Use responsive for fluid layouts where column count depends on available space. Use cols with optional breakpoint attributes (cols-sm, cols-md, etc.) for explicit control.

API Reference ​

ore-grid

AttributeTypeDefaultDescription
cols'1'–'12' | 'auto'-Number of columns
cols-sm'1'–'12' | 'auto'-Columns when element width ≥ 640px
cols-md'1'–'12' | 'auto'-Columns when element width ≥ 768px
cols-lg'1'–'12' | 'auto'-Columns when element width ≥ 1024px
cols-xl'1'–'12' | 'auto'-Columns when element width ≥ 1280px
cols-2xl'1'–'12' | 'auto'-Columns when element width ≥ 1536px
rows'1'–'12' | 'auto'-Number of explicit rows
gap'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl''md'Gap between items
align'start' | 'center' | 'end' | 'stretch' | 'baseline'-align-items for all cells
justify'start' | 'center' | 'end' | 'stretch'-justify-items for all cells
flow'row' | 'column' | 'row-dense' | 'column-dense''row'grid-auto-flow direction
responsivebooleanfalseEnable auto-fit mode
min-col-widthstring--grid-min-item-widthMinimum column width in responsive mode
fullwidthbooleanfalseStretch the grid to fill its container's width
areasstring-CSS grid-template-areas value
areas-smstring-grid-template-areas when element width ≥ 640px
areas-mdstring-grid-template-areas when element width ≥ 768px
areas-lgstring-grid-template-areas when element width ≥ 1024px
areas-xlstring-grid-template-areas when element width ≥ 1280px
areas-2xlstring-grid-template-areas when element width ≥ 1536px

ore-grid-item

AttributeTypeDefaultDescription
col-span'1'–'12' | 'full'-Columns to span; 'full' = 1 / -1
row-span'1'–'6' | 'full'-Rows to span; 'full' = 1 / -1
colstring-Raw grid-column value: overrides col-span
rowstring-Raw grid-row value: overrides row-span
align'start' | 'center' | 'end' | 'stretch'-align-self for this cell
justify'start' | 'center' | 'end' | 'stretch'-justify-self for this cell

CSS Custom Properties ​

These are fallback values: attributes take precedence when set. Fixed column counts resolve through the --grid-1–--grid-12 theme tokens, so a theme can redefine the track sizing globally.

PropertyDefaultDescription
--grid-cols-Fallback column template
--grid-rows-Fallback row template
--grid-gapvar(--size-4)Fallback gap
--grid-row-gapvar(--grid-gap)Fallback row gap
--grid-col-gapvar(--grid-gap)Fallback column gap
--grid-min-item-width15.625rem (250px)Floor for auto-fit column width

Examples ​

Dashboard Layout ​

Full width

Asymmetric Layout ​

Full width

Bento-style Layout with Named Areas ​

Full width

Accessibility ​

The grid component follows WAI-ARIA best practices. It maintains semantic HTML structure and document reading order by default: grid layout is purely visual, and keyboard navigation follows DOM order. The component is compatible with screen readers.

Be mindful of visual vs. DOM order when using flow="dense" or explicit item placement. When using dense packing modes, items may appear in a different visual order than their DOM position, which can confuse screen reader users and keyboard navigators.