Grid

Grid allows users to build applications based on CSS Grid Layout. It is a technical component that abstracts users from working directly with CSS Grid properties and allows them to write more consistent and semantic layouts.

Props

NameTypeDescriptionDefault
autoColumnsstringSets the grid-auto-columns CSS property. See MDN for further information.'auto'
autoFlow'row' | 'column' | 'row dense' | 'column dense'Sets the grid-auto-flow CSS property. See MDN for further information.'row'
autoRowsstringSets the grid-auto-rows CSS property. See MDN for further information.'auto'
gap'0rem' | '0.125rem' | '0.25rem' | '0.5rem' | '1rem' | '1.5rem' | '2rem' | '3rem' | '4rem' | '5rem' | GapSets the gap CSS property. See MDN for further information. It can be either a value from the range or an object with the following properties:
  • rowGap: gutter between rows.
  • columnGap: gutter between columns.
'0rem'
placeContent'normal' | 'start' | 'end' | 'center' | 'stretch' | 'space-between' | 'space-around' | 'space-evenly' | 'baseline' | PlaceContentSets the place-content CSS property. See MDN for further information. It can be either a value from the range or an object with the following properties:
  • justifyContent: aligns the grid along the inline (row) axis.
  • alignContent: aligns the grid along the block (column) axis.
'normal'
placeItems'normal' | 'start' | 'end' | 'center' | 'stretch' | 'baseline' | PlaceItemsSets the place-items CSS property. See MDN for further information. It can be either a value from the range or an object with the following properties:
  • justifyItems: aligns grid items along the inline (row) axis.
  • alignItems: aligns grid items along the block (column) axis.
'normal'
templateAreasstring[]Sets the grid-template-areas CSS property. See MDN for further information.-
templateColumnsstring[]Sets the grid-template-columns CSS property. See MDN for further information.-
templateRowsstring[]Sets the grid-template-rows CSS property. See MDN for further information.-
askeyof HTMLElementTagNameMapSets a custom HTML tag.'div'
Required
children
React.ReactNodeCustom content inside the grid container.-

DxcGrid.Item

Compound component representing a child of a grid container. It provides specific placement controls of how individual items stack or align within the grid.

Every DxcGrid.Item's prop is also available in DxcGrid to facilitate the nesting of grid containers.

Props

NameTypeDescriptionDefault
areaNamestringSets the name of an item so that it can be referenced by a template created with the grid-template-areas property.-
columnnumber | string | GridCellSets the grid-column CSS property. See MDN for further information. It can be either a value from the range or an object with the following properties:
  • start: starting position within the grid column.
  • end: ending position within the grid column.
-
rownumber | string | GridCellSets the grid-row CSS property. See MDN for further information. It can be either a value from the range or an object with the following properties:
  • start: starting position within the grid row.
  • end: ending position within the grid row.
-
placeSelf'auto' | 'start' | 'end' | 'center' | 'stretch' | 'baseline' | PlaceSelfSets the place-self CSS property. See MDN for further information. It can be either a value from the range or an object with the following properties:
  • justifySelf: aligns a grid item inside a cell along the inline (row) axis.
  • alignSelf: aligns a grid item inside a cell along the block (column) axis.
'auto'
askeyof HTMLElementTagNameMapSets a custom HTML tag.'div'
Required
children
React.ReactNodeCustom content inside the grid item container.-

Examples

Basic usage

Building an application layout