Skip to content

Description

Layout.GridItem is a building block for CSS grid based layout of contents and components. Should be used in combination with GridContainer.

The columns do change based on what breakpoint the browser is in:

  • 4 columns when small
  • 6 columns when medium
  • 12 columns when large

Span

You need to provide a span prop with a number from 1 to 12 (can be changed in GridContainer with the columns property).

The span will be used to specify where the item is placed in the grid columns.

A span needs always two numbers – from and to.

uses 50% in width
uses 50% in width
Code Editor
<Layout.GridContainer>
  <Layout.GridItem span={[1, 6]}>uses 50% in width</Layout.GridItem>
  <Layout.GridItem span={[7, 12]}>uses 50% in width</Layout.GridItem>
</Layout.GridContainer>

Example of spans:

  • span={[1, 'end']}
  • span={{ small: [1, 4], medium: [1, 6], large: [1, 12]}}

Responsive spans

You can also make spans respond to media queries.

For doing so, provide a span prop with an object containing Media Query types. Each media size should contain a span, like mentioned above.

uses 50% or 100% based on the screen size
uses 50% or 100% based on the screen size
Code Editor
<Layout.GridContainer>
  <Layout.GridItem
    span={{
      small: [1, 12],
      large: [1, 6],
    }}
  >
    uses 50% or 100% based on the screen size
  </Layout.GridItem>
  <Layout.GridItem
    span={{
      small: [1, 12],
      large: [7, 12],
    }}
  >
    uses 50% or 100% based on the screen size
  </Layout.GridItem>
</Layout.GridContainer>