1. Layout
  2. Grid

Layout

Grid

Creates a grid layout to align components as equally sized columns.

Cards aligned in a Grid

   

Import Grid components

Tremor exports two components for to create a Grid.

import { Grid, Col } from "@tremor/react";

Usage example

The example below shows how a Grid can be used to display Kpi Cards in a grid layout. Note that the number of columns (numCols) as well as the number of columns a single column should span over (numColSpan) can be set for each viewport.

Title

KPI 1

Title

KPI 2

Title

KPI 3

Title

KPI 4

Title

KPI 5

import { Grid, Col, Card, Text, Metric } from "@tremor/react";

export default () => (
    <Grid numCols={1} numColsSm={2} numColsLg={3} className="gap-2">
        <Col numColSpan={1} numColSpanLg={2}>
            <Card>
              <Text>Title</Text>
              <Metric>KPI 1</Metric>
            </Card>
        </Col>
        <Card>
          <Text>Title</Text>
          <Metric>KPI 2</Metric>
        </Card>
        <Col>
            <Card>
              <Text>Title</Text>
              <Metric>KPI 3</Metric>
            </Card>
        </Col>
        <Card>
          <Text>Title</Text>
          <Metric>KPI 4</Metric>
        </Card>
        <Card>
          <Text>Title</Text>
          <Metric>KPI 5</Metric>
        </Card>
    </Grid>
);

API Reference: Grid

numColsoptional
Description
Set how how many columns the grid should have.
Type
number
Default
1
Values
numColsSmoptional
Description
Set how how many columns the grid should have, starting from the sm screen size.
Type
number
Default
Values
numColsMdoptional
Description
Set how how many columns the grid should have, starting from the md screen size.
Type
number
Default
Values
numColsLgoptional
Description
Set how how many columns the grid should have, starting from the lg screen size.
Type
number
Default
Values

API Reference: Col

numColSpanoptional
Description
Control to make an element span over n columns
Type
number
Default
1
Values
numColsSmoptional
Description
Control to make an element span over n columns, starting from the sm screen size
Type
number
Default
Values
numColsMdoptional
Description
Control to make an element span over n rows, starting from the md screen size
Type
number
Default
Values
numColsLgoptional
Description
Control to make an element span over n rows, starting from the lg screen size
Type
number
Default
Values