Examples

Responsive columns

Preview
Main — 3 of 4 columns from md
Aside
Full-width row
Example.tsx
import { Box, Grid, GridItem } from '@reactloom/ui';

const Cell = ({ children }: { children: string }) => (
  <Box padding="4" background="subtle" radius="md" bordered style={{ height: '100%' }}>{children}</Box>
);

export default function Example() {
  return (
    <Grid columns={{ base: 1, md: 4 }} gap="4" style={{ width: '100%' }}>
      <GridItem colSpan={{ base: 'full', md: 3 }}><Cell>Main — 3 of 4 columns from md</Cell></GridItem>
      <Cell>Aside</Cell>
      <GridItem colSpan="full"><Cell>Full-width row</Cell></GridItem>
    </Grid>
  );
}

Auto-fitting columns

minChildWidth needs no breakpoints.

Preview

Revenue

—

Customers

—

Churn

—

Tickets

—

NPS

—

MRR

—

Example.tsx
import { Card, SimpleGrid } from '@reactloom/ui';

export default function Example() {
  // As many 12rem columns as fit — no breakpoints needed.
  return (
    <SimpleGrid minChildWidth="12rem" gap="4" style={{ width: '100%' }}>
      {['Revenue', 'Customers', 'Churn', 'Tickets', 'NPS', 'MRR'].map((name) => (
        <Card key={name} padding="sm">
          <Card.Description>{name}</Card.Description>
          <Card.Title>—</Card.Title>
        </Card>
      ))}
    </SimpleGrid>
  );
}

API reference

Grid props

Grid props
PropTypeDefault
columns
A count or any grid-template-columns value.
Responsive<number | string>—
gap
Responsive<Space>'4'
alignItems
'start' | 'center' | 'end' | 'stretch'—

GridItem props

GridItem props
PropTypeDefault
colSpan
Responsive<number | 'full'>—

SimpleGrid props

SimpleGrid props
PropTypeDefault
minChildWidth
e.g. "12rem".
string—
columns
Responsive<number>—
gap
Responsive<Space>'4'

Customization

Extracted from the component’s source on every build, so it matches the code. How the layers fit together is explained in Customization.

State attributes

Target these in your CSS to style states without depending on class names.

AttributeValues
[data-align]present when on

Accessibility

  • Keep DOM order equal to visual order.

Usage guidelines

Do

  • Use SimpleGrid for card collections.

Don’t

  • Don’t reorder content visually with grid placement.