- Implementation
- Grid Props
- Grid.Item Props
Usage Guidelines
UseGrid when children need both row and column placement inside a section or component. Grid is a CSS Grid container for two-dimensional layout. Prefer Layout for the page’s overall columns.Alternatives
- Layout for page-level 12-column structure.
- Flex for one main axis, wrapping, and flex item grow and shrink.
- Layout props on Card (and similar) when the cell component already accepts grid placement props.
How to Use
ImportGrid and set the column tracks on the container. Use Grid.Item when the cell needs placement props and is not already a component that accepts them. The playground uses Card only to visualize areas. See Card usage guidelines.Grid and Grid.Item render div elements with no role and no keyboard behavior. Name a region only with a supported role (for example role="region") plus aria-label or aria-labelledby. Keep source order in the intended reading sequence.Common Examples
Creating CSS Grid layouts
TheGrid component renders a div with display: grid. Set inline to render display: inline-grid instead. Track sizing, placement, alignment, and spacing are props. Each prop is written as an inline style and maps to a CSS property.Grid.Item renders the cell: a div that accepts placement props such as gridColumn, gridRow, and alignSelf. Any child can sit in the grid. Use Grid.Item when the cell needs those props and is not already a component that accepts layout utilities. The playground puts gridColumn and gridRow on Card because Card accepts those props directly.A Grid is always a grid container. Nested inside another Grid, it is also a grid item, and the placement props apply to that outer grid. Nested inside Flex, it is a flex item, and the flex item props apply.Layout props are merged after style, so they override the same CSS property set on style. className is combined with the component class.Responsive props
sm, md, lg, xl, and xxl override props from that viewport width up. Widths come from the Hammer breakpoints:Base props apply at every width, including below
640px. There is no xs prop. Each property resolves on its own: the largest matching breakpoint that sets it wins, and otherwise the base value is used.A breakpoint object accepts the container, placement, and flex props. It does not accept inline. Nested sm, md, lg, xl, or xxl keys inside a breakpoint object are ignored.The example below is one column by default and two columns from md up.React Accessibility
Grid and Grid.Item render div elements. They do not set a role, and they do not handle keyboard interaction. Put focusable controls in the cell content. A generic div does not receive an accessible name from aria-label or aria-labelledby alone. To name the region, set a role that supports an accessible name, such as role="region", together with aria-label or aria-labelledby.gridColumn, gridRow, and order change visual position only. Assistive technology follows DOM order. Keep the source order in the reading sequence you want announced.