Skip to main content

Grid

The grid component organizes content in a matrix of rows and columns to create responsive page layouts. Use grid to build complex, multi-column layouts that adapt to different screen sizes and maintain consistent alignment.

Grid follows the CSS grid layout pattern and supports flexible column configurations, gap spacing, and alignment properties for precise layout control. For simpler linear layouts (horizontal or vertical), use stack.


Configure the following properties on the grid component.

Anchor to gridTemplateColumns
gridTemplateColumns
string
Default: 'none'
required

The columns in the grid and their sizes.

Accepts:

Anchor to gridTemplateRows
gridTemplateRows
string
Default: 'none'
required

The rows in the grid and their sizes.

Accepts:

Anchor to justifyItems
justifyItems
"" |
Default: '' - meaning no override
required

Aligns the grid items along the inline axis.

Anchor to alignItems
alignItems
"" |
Default: '' - meaning no override
required

Aligns the grid items along the block axis.

Anchor to placeItems
placeItems
| "normal normal" | "normal stretch" | "normal baseline" | "normal first baseline" | "normal last baseline" | "normal start" | "normal end" | "normal center" | "normal unsafe start" | "normal unsafe end" | "normal unsafe center" | "normal safe start" | "normal safe end" | "normal safe center" | "stretch normal" | "stretch stretch" | "stretch baseline" | "stretch first baseline" | "stretch last baseline" | "stretch start" | "stretch end" | "stretch center" | "stretch unsafe start" | "stretch unsafe end" | "stretch unsafe center" | "stretch safe start" | "stretch safe end" | "stretch safe center" | "baseline normal" | "baseline stretch" | "baseline baseline" | "baseline first baseline" | "baseline last baseline" | "baseline start" | "baseline end" | "baseline center" | "baseline unsafe start" | "baseline unsafe end" | "baseline unsafe center" | "baseline safe start" | "baseline safe end" | "baseline safe center" | "first baseline normal" | "first baseline stretch" | "first baseline baseline" | "first baseline first baseline" | "first baseline last baseline" | "first baseline start" | "first baseline end" | "first baseline center" | "first baseline unsafe start" | "first baseline unsafe end" | "first baseline unsafe center" | "first baseline safe start" | "first baseline safe end" | "first baseline safe center" | "last baseline normal" | "last baseline stretch" | "last baseline baseline" | "last baseline first baseline" | "last baseline last baseline" | "last baseline start" | "last baseline end" | "last baseline center" | "last baseline unsafe start" | "last baseline unsafe end" | "last baseline unsafe center" | "last baseline safe start" | "last baseline safe end" | "last baseline safe center" | "start normal" | "start stretch" | "start baseline" | "start first baseline" | "start last baseline" | "start start" | "start end" | "start center" | "start unsafe start" | "start unsafe end" | "start unsafe center" | "start safe start" | "start safe end" | "start safe center" | "end normal" | "end stretch" | "end baseline" | "end first baseline" | "end last baseline" | "end start" | "end end" | "end center" | "end unsafe start" | "end unsafe end" | "end unsafe center" | "end safe start" | "end safe end" | "end safe center" | "center normal" | "center stretch" | "center baseline" | "center first baseline" | "center last baseline" | "center start" | "center end" | "center center" | "center unsafe start" | "center unsafe end" | "center unsafe center" | "center safe start" | "center safe end" | "center safe center" | "unsafe start normal" | "unsafe start stretch" | "unsafe start baseline" | "unsafe start first baseline" | "unsafe start last baseline" | "unsafe start start" | "unsafe start end" | "unsafe start center" | "unsafe start unsafe start" | "unsafe start unsafe end" | "unsafe start unsafe center" | "unsafe start safe start" | "unsafe start safe end" | "unsafe start safe center" | "unsafe end normal" | "unsafe end stretch" | "unsafe end baseline" | "unsafe end first baseline" | "unsafe end last baseline" | "unsafe end start" | "unsafe end end" | "unsafe end center" | "unsafe end unsafe start" | "unsafe end unsafe end" | "unsafe end unsafe center" | "unsafe end safe start" | "unsafe end safe end" | "unsafe end safe center" | "unsafe center normal" | "unsafe center stretch" | "unsafe center baseline" | "unsafe center first baseline" | "unsafe center last baseline" | "unsafe center start" | "unsafe center end" | "unsafe center center" | "unsafe center unsafe start" | "unsafe center unsafe end" | "unsafe center unsafe center" | "unsafe center safe start" | "unsafe center safe end" | "unsafe center safe center" | "safe start normal" | "safe start stretch" | "safe start baseline" | "safe start first baseline" | "safe start last baseline" | "safe start start" | "safe start end" | "safe start center" | "safe start unsafe start" | "safe start unsafe end" | "safe start unsafe center" | "safe start safe start" | "safe start safe end" | "safe start safe center" | "safe end normal" | "safe end stretch" | "safe end baseline" | "safe end first baseline" | "safe end last baseline" | "safe end start" | "safe end end" | "safe end center" | "safe end unsafe start" | "safe end unsafe end" | "safe end unsafe center" | "safe end safe start" | "safe end safe end" | "safe end safe center" | "safe center normal" | "safe center stretch" | "safe center baseline" | "safe center first baseline" | "safe center last baseline" | "safe center start" | "safe center end" | "safe center center" | "safe center unsafe start" | "safe center unsafe end" | "safe center unsafe center" | "safe center safe start" | "safe center safe end" | "safe center safe center"
Default: 'normal normal'
required

A shorthand property for justify-items and align-items.

Anchor to justifyContent
justifyContent
"" |
Default: '' - meaning no override
required

Aligns the grid along the inline axis. This overrides the inline value of placeContent.

Anchor to alignContent
alignContent
"" |
Default: '' - meaning no override
required

Aligns the grid along the block axis. This overrides the block value of placeContent.

Anchor to placeContent
placeContent
"normal normal" | "normal stretch" | "normal start" | "normal end" | "normal center" | "normal unsafe start" | "normal unsafe end" | "normal unsafe center" | "normal safe start" | "normal safe end" | "normal safe center" | "stretch normal" | "stretch stretch" | "stretch start" | "stretch end" | "stretch center" | "stretch unsafe start" | "stretch unsafe end" | "stretch unsafe center" | "stretch safe start" | "stretch safe end" | "stretch safe center" | "baseline normal" | "baseline stretch" | "baseline start" | "baseline end" | "baseline center" | "baseline unsafe start" | "baseline unsafe end" | "baseline unsafe center" | "baseline safe start" | "baseline safe end" | "baseline safe center" | "first baseline normal" | "first baseline stretch" | "first baseline start" | "first baseline end" | "first baseline center" | "first baseline unsafe start" | "first baseline unsafe end" | "first baseline unsafe center" | "first baseline safe start" | "first baseline safe end" | "first baseline safe center" | "last baseline normal" | "last baseline stretch" | "last baseline start" | "last baseline end" | "last baseline center" | "last baseline unsafe start" | "last baseline unsafe end" | "last baseline unsafe center" | "last baseline safe start" | "last baseline safe end" | "last baseline safe center" | "start normal" | "start stretch" | "start start" | "start end" | "start center" | "start unsafe start" | "start unsafe end" | "start unsafe center" | "start safe start" | "start safe end" | "start safe center" | "end normal" | "end stretch" | "end start" | "end end" | "end center" | "end unsafe start" | "end unsafe end" | "end unsafe center" | "end safe start" | "end safe end" | "end safe center" | "center normal" | "center stretch" | "center start" | "center end" | "center center" | "center unsafe start" | "center unsafe end" | "center unsafe center" | "center safe start" | "center safe end" | "center safe center" | "unsafe start normal" | "unsafe start stretch" | "unsafe start start" | "unsafe start end" | "unsafe start center" | "unsafe start unsafe start" | "unsafe start unsafe end" | "unsafe start unsafe center" | "unsafe start safe start" | "unsafe start safe end" | "unsafe start safe center" | "unsafe end normal" | "unsafe end stretch" | "unsafe end start" | "unsafe end end" | "unsafe end center" | "unsafe end unsafe start" | "unsafe end unsafe end" | "unsafe end unsafe center" | "unsafe end safe start" | "unsafe end safe end" | "unsafe end safe center" | "unsafe center normal" | "unsafe center stretch" | "unsafe center start" | "unsafe center end" | "unsafe center center" | "unsafe center unsafe start" | "unsafe center unsafe end" | "unsafe center unsafe center" | "unsafe center safe start" | "unsafe center safe end" | "unsafe center safe center" | "safe start normal" | "safe start stretch" | "safe start start" | "safe start end" | "safe start center" | "safe start unsafe start" | "safe start unsafe end" | "safe start unsafe center" | "safe start safe start" | "safe start safe end" | "safe start safe center" | "safe end normal" | "safe end stretch" | "safe end start" | "safe end end" | "safe end center" | "safe end unsafe start" | "safe end unsafe end" | "safe end unsafe center" | "safe end safe start" | "safe end safe end" | "safe end safe center" | "safe center normal" | "safe center stretch" | "safe center start" | "safe center end" | "safe center center" | "safe center unsafe start" | "safe center unsafe end" | "safe center unsafe center" | "safe center safe start" | "safe center safe end" | "safe center safe center" | | "normal space-between" | "normal space-around" | "normal space-evenly" | "baseline space-between" | "baseline space-around" | "baseline space-evenly" | "first baseline space-between" | "first baseline space-around" | "first baseline space-evenly" | "last baseline space-between" | "last baseline space-around" | "last baseline space-evenly" | "start space-between" | "start space-around" | "start space-evenly" | "end space-between" | "end space-around" | "end space-evenly" | "center space-between" | "center space-around" | "center space-evenly" | "unsafe start space-between" | "unsafe start space-around" | "unsafe start space-evenly" | "unsafe end space-between" | "unsafe end space-around" | "unsafe end space-evenly" | "unsafe center space-between" | "unsafe center space-around" | "unsafe center space-evenly" | "safe start space-between" | "safe start space-around" | "safe start space-evenly" | "safe end space-between" | "safe end space-around" | "safe end space-evenly" | "safe center space-between" | "safe center space-around" | "safe center space-evenly" | "stretch space-between" | "stretch space-around" | "stretch space-evenly" | "space-between normal" | "space-between start" | "space-between end" | "space-between center" | "space-between unsafe start" | "space-between unsafe end" | "space-between unsafe center" | "space-between safe start" | "space-between safe end" | "space-between safe center" | "space-between stretch" | "space-between space-between" | "space-between space-around" | "space-between space-evenly" | "space-around normal" | "space-around start" | "space-around end" | "space-around center" | "space-around unsafe start" | "space-around unsafe end" | "space-around unsafe center" | "space-around safe start" | "space-around safe end" | "space-around safe center" | "space-around stretch" | "space-around space-between" | "space-around space-around" | "space-around space-evenly" | "space-evenly normal" | "space-evenly start" | "space-evenly end" | "space-evenly center" | "space-evenly unsafe start" | "space-evenly unsafe end" | "space-evenly unsafe center" | "space-evenly safe start" | "space-evenly safe end" | "space-evenly safe center" | "space-evenly stretch" | "space-evenly space-between" | "space-evenly space-around" | "space-evenly space-evenly"
Default: 'normal normal'
required

A shorthand property for justify-content and align-content.

<<>>
Default: 'none'
required

Adjusts spacing between elements.

Accepts:

  • A single SpacingKeyword value applied to both axes, such as large-100
  • A pair of values, such as large-100 large-500, to set the inline and block axes respectively
  • A responsive value string with the supported SpacingKeyword as a query value
Anchor to rowGap
rowGap
<"" | >
Default: '' - meaning no override
required

s spacing between elements in the block axis. This overrides the row value of gap.

Accepts:

Anchor to columnGap
columnGap
<"" | >
Default: '' - meaning no override
required

Adjusts spacing between elements in the inline axis. This overrides the column value of gap.

Accepts:

Anchor to accessibilityRole
accessibilityRole
Default: 'generic'
required

The semantic meaning of the component’s content. When set, the role will be used by assistive technologies to help users navigate the page.

Anchor to background
background
Default: 'transparent'
required

The background color of the component.

Anchor to blockSize
blockSize
Default: 'auto'
required

The vertical size of the element in standard layouts (height in left-to-right or right-to-left writing modes).

Block size adjusts based on the writing direction: in horizontal layouts, it controls the height; in vertical layouts, it controls the width. This ensures consistent behavior across different text directions.

Learn more about block-size.

Anchor to minBlockSize
minBlockSize
Default: '0'
required

The minimum height in horizontal writing modes, or minimum width in vertical writing modes. Prevents the element from shrinking below this size.

Learn more about min-block-size.

Anchor to maxBlockSize
maxBlockSize
Default: 'none'
required

The maximum height in horizontal writing modes, or maximum width in vertical writing modes. Prevents the element from growing beyond this size.

Learn more about max-block-size.

Anchor to inlineSize
inlineSize
Default: 'auto'
required

The width in horizontal writing modes, or height in vertical writing modes. Use this for flow-relative sizing that adapts to text direction. Learn more about inline-size.

Anchor to minInlineSize
minInlineSize
Default: '0'
required

The minimum width in horizontal writing modes, or minimum height in vertical writing modes. Prevents the element from shrinking below this size.

Learn more about min-inline-size.

Anchor to maxInlineSize
maxInlineSize
Default: 'none'
required

The maximum width in horizontal writing modes, or maximum height in vertical writing modes. Prevents the element from growing beyond this size.

Learn more about max-inline-size.

Anchor to overflow
overflow
"visible" | "hidden"
Default: 'visible'
required

The overflow behavior of the element.

  • visible: the content that extends beyond the element’s container is visible.
  • hidden: clips the content when it is larger than the element’s container. The element will not be scrollable and the users will not be able to access the clipped content by dragging or using a scroll wheel on a mouse.
Anchor to padding
padding
<<>>
Default: 'none'
required

The padding applied to all edges of the component.

Supports 1-to-4-value syntax using flow-relative values:

  • 1 value applies to all sides
  • 2 values apply to block (top/bottom) and inline (left/right)
  • 3 values apply to block-start (top), inline (left/right), and block-end (bottom)
  • 4 values apply to block-start (top), inline-end (right), block-end (bottom), and inline-start (left)

Examples: base, large none, base large-100 base small

Use auto to inherit padding from the nearest container with removed padding. Also accepts a responsive value string with the supported PaddingKeyword as a query value.

Anchor to paddingBlock
paddingBlock
<"" | <>>
Default: '' - meaning no override
required

The block-direction padding (top and bottom in horizontal writing modes).

Accepts a single value for both sides or two space-separated values for block-start and block-end.

Example: large none applies large to the top and none to the bottom.

Overrides the block value from padding. Also accepts a responsive value string with the supported PaddingKeyword as a query value.

Anchor to paddingBlockStart
paddingBlockStart
<"" | >
Default: '' - meaning no override
required

The block-start padding (top in horizontal writing modes).

Overrides the block-start value from paddingBlock. Also accepts a responsive value string with the supported PaddingKeyword as a query value.

Anchor to paddingBlockEnd
paddingBlockEnd
<"" | >
Default: '' - meaning no override
required

The block-end padding (bottom in horizontal writing modes).

Overrides the block-end value from paddingBlock. Also accepts a responsive value string with the supported PaddingKeyword as a query value.

Anchor to paddingInline
paddingInline
<"" | <>>
Default: '' - meaning no override
required

The inline-direction padding (left and right in horizontal writing modes).

Accepts a single value for both sides or two space-separated values for inline-start and inline-end.

Example: large none applies large to the left and none to the right.

Overrides the inline value from padding. Also accepts a responsive value string with the supported PaddingKeyword as a query value.

Anchor to paddingInlineStart
paddingInlineStart
<"" | >
Default: '' - meaning no override
required

The inline-start padding (left in LTR writing modes, right in RTL).

Overrides the inline-start value from paddingInline. Also accepts a responsive value string with the supported PaddingKeyword as a query value.

Anchor to paddingInlineEnd
paddingInlineEnd
<"" | >
Default: '' - meaning no override
required

The inline-end padding (right in LTR writing modes, left in RTL).

Overrides the inline-end value from paddingInline. Also accepts a responsive value string with the supported PaddingKeyword as a query value.

Anchor to border
border
Default: 'none' - equivalent to `none base auto`.
required

A border applied using shorthand syntax to specify width, color, and style in a single property.

Anchor to borderWidth
borderWidth
"" | <"small" | "small-100" | "base" | "large" | "large-100" | "none">
Default: '' - meaning no override
required

The thickness of the border on all sides. When set, this overrides the width value specified in the border property.

Anchor to borderStyle
borderStyle
"" | <>
Default: '' - meaning no override
required

The visual style of the border on all sides, such as solid, dashed, or dotted. When set, this overrides the style value specified in the border property.

Anchor to borderColor
borderColor
"" |
Default: '' - meaning no override
required

The color of the border using the design system's color scale. When set, this overrides the color value specified in the border property.

Anchor to borderRadius
borderRadius
<>
Default: 'none'
required

The roundedness of the element's corners using the design system's radius scale.

Anchor to accessibilityLabel
accessibilityLabel
string
required

A label that describes the purpose or content of the component for assistive technologies like screen readers. Use this to provide additional context when the visible content alone doesn't clearly convey the component's purpose.

Anchor to accessibilityVisibility
accessibilityVisibility
"visible" | "hidden" | "exclusive"
Default: 'visible'
required

The visibility mode of the element for both visual and assistive technology users.

  • visible: The element is visible to all users (both sighted users and screen readers).
  • hidden: The element is visually visible but hidden from screen readers. Use this for decorative elements that don't provide meaningful information.
  • exclusive: The element is visually hidden but announced by screen readers. Use this for screen-reader-only content like skip links or additional context.
Anchor to display
display
<"auto" | "none">
Default: 'auto'
required

The outer display type of the component. The outer type sets a component's participation in flow layout.

  • auto the component's initial value. The actual value depends on the component and context.
  • none hides the component from display and removes it from the accessibility tree, making it invisible to screen readers.

The grid component supports slots for additional content placement within the component. Learn more about using slots.

Anchor to children
children
HTMLElement

The child elements displayed within the grid component, which are arranged in a flexible grid layout with configurable columns, rows, and spacing.


The grid item component represents a single cell within a grid layout, allowing you to control how content is positioned and sized within the grid. Use grid item as a child of grid to specify column span, row span, and positioning for individual content areas.

Grid item supports precise placement control through column and row properties, enabling you to create complex layouts where different items occupy varying amounts of space or appear in specific grid positions.

Anchor to gridColumn
gridColumn
"auto" | `span ${number}`
Default: 'auto'
required

The number of columns the item will span across.

Learn more about the grid-column property.

Anchor to gridRow
gridRow
"auto" | `span ${number}`
Default: 'auto'
required

The number of rows the item will span across.

Learn more about the grid-row property.

Anchor to accessibilityRole
accessibilityRole
Default: 'generic'
required

The semantic meaning of the component’s content. When set, the role will be used by assistive technologies to help users navigate the page.

Anchor to background
background
Default: 'transparent'
required

The background color of the component.

Anchor to blockSize
blockSize
Default: 'auto'
required

The vertical size of the element in standard layouts (height in left-to-right or right-to-left writing modes).

Block size adjusts based on the writing direction: in horizontal layouts, it controls the height; in vertical layouts, it controls the width. This ensures consistent behavior across different text directions.

Learn more about block-size.

Anchor to minBlockSize
minBlockSize
Default: '0'
required

The minimum height in horizontal writing modes, or minimum width in vertical writing modes. Prevents the element from shrinking below this size.

Learn more about min-block-size.

Anchor to maxBlockSize
maxBlockSize
Default: 'none'
required

The maximum height in horizontal writing modes, or maximum width in vertical writing modes. Prevents the element from growing beyond this size.

Learn more about max-block-size.

Anchor to inlineSize
inlineSize
Default: 'auto'
required

The width in horizontal writing modes, or height in vertical writing modes. Use this for flow-relative sizing that adapts to text direction. Learn more about inline-size.

Anchor to minInlineSize
minInlineSize
Default: '0'
required

The minimum width in horizontal writing modes, or minimum height in vertical writing modes. Prevents the element from shrinking below this size.

Learn more about min-inline-size.

Anchor to maxInlineSize
maxInlineSize
Default: 'none'
required

The maximum width in horizontal writing modes, or maximum height in vertical writing modes. Prevents the element from growing beyond this size.

Learn more about max-inline-size.

Anchor to overflow
overflow
"visible" | "hidden"
Default: 'visible'
required

The overflow behavior of the element.

  • visible: the content that extends beyond the element’s container is visible.
  • hidden: clips the content when it is larger than the element’s container. The element will not be scrollable and the users will not be able to access the clipped content by dragging or using a scroll wheel on a mouse.
Anchor to padding
padding
<<>>
Default: 'none'
required

The padding applied to all edges of the component.

Supports 1-to-4-value syntax using flow-relative values:

  • 1 value applies to all sides
  • 2 values apply to block (top/bottom) and inline (left/right)
  • 3 values apply to block-start (top), inline (left/right), and block-end (bottom)
  • 4 values apply to block-start (top), inline-end (right), block-end (bottom), and inline-start (left)

Examples: base, large none, base large-100 base small

Use auto to inherit padding from the nearest container with removed padding. Also accepts a responsive value string with the supported PaddingKeyword as a query value.

Anchor to paddingBlock
paddingBlock
<"" | <>>
Default: '' - meaning no override
required

The block-direction padding (top and bottom in horizontal writing modes).

Accepts a single value for both sides or two space-separated values for block-start and block-end.

Example: large none applies large to the top and none to the bottom.

Overrides the block value from padding. Also accepts a responsive value string with the supported PaddingKeyword as a query value.

Anchor to paddingBlockStart
paddingBlockStart
<"" | >
Default: '' - meaning no override
required

The block-start padding (top in horizontal writing modes).

Overrides the block-start value from paddingBlock. Also accepts a responsive value string with the supported PaddingKeyword as a query value.

Anchor to paddingBlockEnd
paddingBlockEnd
<"" | >
Default: '' - meaning no override
required

The block-end padding (bottom in horizontal writing modes).

Overrides the block-end value from paddingBlock. Also accepts a responsive value string with the supported PaddingKeyword as a query value.

Anchor to paddingInline
paddingInline
<"" | <>>
Default: '' - meaning no override
required

The inline-direction padding (left and right in horizontal writing modes).

Accepts a single value for both sides or two space-separated values for inline-start and inline-end.

Example: large none applies large to the left and none to the right.

Overrides the inline value from padding. Also accepts a responsive value string with the supported PaddingKeyword as a query value.

Anchor to paddingInlineStart
paddingInlineStart
<"" | >
Default: '' - meaning no override
required

The inline-start padding (left in LTR writing modes, right in RTL).

Overrides the inline-start value from paddingInline. Also accepts a responsive value string with the supported PaddingKeyword as a query value.

Anchor to paddingInlineEnd
paddingInlineEnd
<"" | >
Default: '' - meaning no override
required

The inline-end padding (right in LTR writing modes, left in RTL).

Overrides the inline-end value from paddingInline. Also accepts a responsive value string with the supported PaddingKeyword as a query value.

Anchor to border
border
Default: 'none' - equivalent to `none base auto`.
required

A border applied using shorthand syntax to specify width, color, and style in a single property.

Anchor to borderWidth
borderWidth
"" | <"small" | "small-100" | "base" | "large" | "large-100" | "none">
Default: '' - meaning no override
required

The thickness of the border on all sides. When set, this overrides the width value specified in the border property.

Anchor to borderStyle
borderStyle
"" | <>
Default: '' - meaning no override
required

The visual style of the border on all sides, such as solid, dashed, or dotted. When set, this overrides the style value specified in the border property.

Anchor to borderColor
borderColor
"" |
Default: '' - meaning no override
required

The color of the border using the design system's color scale. When set, this overrides the color value specified in the border property.

Anchor to borderRadius
borderRadius
<>
Default: 'none'
required

The roundedness of the element's corners using the design system's radius scale.

Anchor to accessibilityLabel
accessibilityLabel
string
required

A label that describes the purpose or content of the component for assistive technologies like screen readers. Use this to provide additional context when the visible content alone doesn't clearly convey the component's purpose.

Anchor to accessibilityVisibility
accessibilityVisibility
"visible" | "hidden" | "exclusive"
Default: 'visible'
required

The visibility mode of the element for both visual and assistive technology users.

  • visible: The element is visible to all users (both sighted users and screen readers).
  • hidden: The element is visually visible but hidden from screen readers. Use this for decorative elements that don't provide meaningful information.
  • exclusive: The element is visually hidden but announced by screen readers. Use this for screen-reader-only content like skip links or additional context.
Anchor to display
display
<"auto" | "none">
Default: 'auto'
required

The outer display type of the component. The outer type sets a component's participation in flow layout.

  • auto the component's initial value. The actual value depends on the component and context.
  • none hides the component from display and removes it from the accessibility tree, making it invisible to screen readers.

The grid item component supports slots for additional content placement within the component. Learn more about using slots.

Anchor to children
children
HTMLElement

The content displayed within the grid item component, which represents a single cell in the grid layout and can span multiple columns or rows.


Anchor to Add a grid layout with column spansAdd a grid layout with column spans

Create a grid layout with columns and grid items that span them. This example shows a two-column grid with a full-width header row and two equal columns below.

Preview

html

<s-grid
gridTemplateColumns="repeat(2, 1fr)"
gap="small"
justifyContent="center"
>
<s-grid-item gridColumn="span 2" border="base" borderStyle="dashed">
Summary of sales
</s-grid-item>
<s-grid-item gridColumn="span 1" border="base" borderStyle="dashed">
Orders
</s-grid-item>
<s-grid-item gridColumn="auto" border="base" borderStyle="dashed">
Customers
</s-grid-item>
</s-grid>

Anchor to Create a two-column layoutCreate a two-column layout

Create a simple two-column layout. This example uses a 12-column grid system with equal-width columns.

Preview

html

<s-grid gridTemplateColumns="repeat(12, 1fr)" gap="base">
<s-grid-item gridColumn="span 6" gridRow="span 1">
<s-section>
<s-text>Left column</s-text>
</s-section>
</s-grid-item>
<s-grid-item gridColumn="span 6" gridRow="span 1">
<s-section>
<s-text>Right column</s-text>
</s-section>
</s-grid-item>
</s-grid>

Anchor to Build layouts with column spansBuild layouts with column spans

Use a 12-column grid system with spans to create full-width, half-width, and third-width column arrangements. This example shows multiple rows with progressively narrower columns.

Preview

html

<s-stack gap="base">
<s-grid gridTemplateColumns="repeat(12, 1fr)" gap="base">
<s-grid-item gridColumn="span 12" gridRow="span 1">
<s-section>
<s-text>Full width field</s-text>
</s-section>
</s-grid-item>
<s-grid-item gridColumn="span 6" gridRow="span 2">
<s-section>
<s-text>Half width field</s-text>
</s-section>
</s-grid-item>
<s-grid-item gridColumn="span 6" gridRow="span 2">
<s-section>
<s-text>Half width field</s-text>
</s-section>
</s-grid-item>
<s-grid-item gridColumn="span 4" gridRow="span 3">
<s-section>
<s-text>Third width field</s-text>
</s-section>
</s-grid-item>
<s-grid-item gridColumn="span 4" gridRow="span 3">
<s-section>
<s-text>Third width field</s-text>
</s-section>
</s-grid-item>
<s-grid-item gridColumn="span 4" gridRow="span 3">
<s-section>
<s-text>Third width field</s-text>
</s-section>
</s-grid-item>
</s-grid>
</s-stack>

Anchor to Create a responsive grid with container queriesCreate a responsive grid with container queries

Use the gridTemplateColumns property with container queries to automatically adjust the column count based on available width. This example shows a grid that switches from a single column in narrow containers to three columns in wider ones.

Preview

html

<s-stack gap="base">
<s-text type="strong">Narrow container (375px)</s-text>
<s-box inlineSize="375px">
<s-query-container>
<s-grid
gridTemplateColumns="@container (inline-size > 400px) 1fr 1fr 1fr, 1fr"
gap="base"
>
<s-grid-item>
<s-box padding="small" background="subdued">
<s-text>Item 1</s-text>
</s-box>
</s-grid-item>
<s-grid-item>
<s-box padding="small" background="subdued">
<s-text>Item 2</s-text>
</s-box>
</s-grid-item>
<s-grid-item>
<s-box padding="small" background="subdued">
<s-text>Item 3</s-text>
</s-box>
</s-grid-item>
</s-grid>
</s-query-container>
</s-box>

<s-text type="strong">Wide container (450px)</s-text>
<s-box inlineSize="450px">
<s-query-container>
<s-grid
gridTemplateColumns="@container (inline-size > 400px) 1fr 1fr 1fr, 1fr"
gap="base"
>
<s-grid-item>
<s-box padding="small" background="subdued">
<s-text>Item 1</s-text>
</s-box>
</s-grid-item>
<s-grid-item>
<s-box padding="small" background="subdued">
<s-text>Item 2</s-text>
</s-box>
</s-grid-item>
<s-grid-item>
<s-box padding="small" background="subdued">
<s-text>Item 3</s-text>
</s-box>
</s-grid-item>
</s-grid>
</s-query-container>
</s-box>
</s-stack>

  • Design for different screen sizes: Layouts that work well on desktop often fail on mobile. Plan how your grid should reflow or reconfigure for smaller screens rather than creating a fixed layout that doesn't adapt.
  • Keep spacing consistent: Consistent spacing between grid items creates visual rhythm and makes layouts easier to scan. Avoid mixing different spacing approaches within the same grid.
  • Consider content overflow: Grid cells have fixed dimensions, but content length varies. Plan how your layout handles content that's too long or too wide, whether through wrapping, truncation, or scrolling.
  • Use semantic alternatives when appropriate: Before using the component, consider whether simpler layout components would work. Grid's power comes with complexity, so use it when you need its specific capabilities.

  • The component doesn't support CSS subgrid for aligning nested grid tracks with parent grids. If you need nested grids to align with parent grid lines, you'll need to manually coordinate the sizing or use a different layout approach.

Was this page helpful?