PPolaris ComponentsConnect an agent

Grid

A 12-column responsive grid where each Grid.Cell declares how many columns it spans at every breakpoint.

Preview

Code

Example.jsx
import { Card, Box, BlockStack, Grid, Text } from '@shopify/polaris';

const KPIS = [
  { id: 'sessions', label: 'Sessions', value: '18,420' },
  { id: 'orders', label: 'Orders', value: '1,236' },
  { id: 'aov', label: 'Average order value', value: '$84.10' },
  { id: 'revenue', label: 'Revenue', value: '$103,760' },
];

const Panel = ({ label, value, height }) => (
  <Box background="bg-surface-secondary" borderRadius="200" padding="400" minHeight={height}>
    <BlockStack gap="100">
      <Text as="span" variant="bodySm" tone="subdued">
        {label}
      </Text>
      {value && (
        <Text as="span" variant="headingLg" fontWeight="semibold">
          {value}
        </Text>
      )}
    </BlockStack>
  </Box>
);

export const Example = () => (
  <Card>
    <BlockStack gap="500">
      <BlockStack gap="200">
        <Text as="h3" variant="headingSm">
          Four cells, three columns each on desktop
        </Text>
        <Grid>
          {KPIS.map((kpi) => (
            <Grid.Cell key={kpi.id} columnSpan={{ xs: 6, sm: 3, md: 3, lg: 3, xl: 3 }}>
              <Panel label={kpi.label} value={kpi.value} />
            </Grid.Cell>
          ))}
        </Grid>
      </BlockStack>

      <BlockStack gap="200">
        <Text as="h3" variant="headingSm">
          An eight / four split
        </Text>
        <Grid>
          <Grid.Cell columnSpan={{ xs: 6, sm: 6, md: 4, lg: 8, xl: 8 }}>
            <Panel label="columnSpan lg: 8 — sales over time" height="140px" />
          </Grid.Cell>
          <Grid.Cell columnSpan={{ xs: 6, sm: 6, md: 2, lg: 4, xl: 4 }}>
            <Panel label="columnSpan lg: 4 — top products" height="140px" />
          </Grid.Cell>
        </Grid>
      </BlockStack>

      <BlockStack gap="200">
        <Text as="h3" variant="headingSm">
          Explicit placement with columnStart
        </Text>
        <Grid>
          <Grid.Cell columnSpan={{ xs: 6, sm: 6, md: 6, lg: 6, xl: 6 }}>
            <Panel label="columnSpan 6" />
          </Grid.Cell>
          <Grid.Cell columnStart={{ lg: 10 }} columnSpan={{ xs: 6, sm: 6, md: 6, lg: 3, xl: 3 }}>
            <Panel label="columnStart lg: 10" />
          </Grid.Cell>
        </Grid>
      </BlockStack>
    </BlockStack>
  </Card>
);