Grid

Lays out its children on a CSS grid of rows and columns.

Usage

Code
import { Grid, GridItem } from '@leverui/components';

export function GridUsage() {
  return (
    <Grid templateColumns="repeat(2, minmax(0, 1fr))" class="grid-usage">
      <GridItem>First item</GridItem>
      <GridItem>Second item</GridItem>
    </Grid>
  );
}
Code
.grid-usage {
  gap: var(--leverui-spacing-4);
}

Examples

Col Span

Pass colSpan to make a GridItem span columns.

Spanning Columns

Span specific columns or rows in a grid layout.

rowSpan=2
colSpan=2
colSpan=2
colSpan=4

Props

PropDefaultTypeDescription
templateColumns—CSS grid track listColumns of the grid.
autoFlow—CSS grid auto-flow valueDirection auto-placed items fill the grid.
autoRows—CSS grid track sizeSize of rows the grid adds on its own.
autoColumns—CSS grid track sizeSize of columns the grid adds on its own.
templateRows—CSS grid track listRows of the grid.
templateAreas—CSS grid area mapNamed areas to place items in.
column—CSS grid-column valueColumns this grid takes up in a parent grid.
row—CSS grid-row valueRows this grid takes up in a parent grid.
inlinefalseBooleanUse inline-grid in place of grid.
asdivNative HTML tagHTML tag to render.
asChild—Solid render callbackRender your own element as the root.
unstyledfalseBooleanTurn off the Lever UI styles.

GridItem accepts area, colSpan, rowSpan, colStart, colEnd, rowStart, and rowEnd. A number for colSpan or rowSpan becomes a CSS span value. Responsive values work at the standard breakpoints. Set the gap and other styles in a CSS class.

Placing items can change the visual order. Keep the DOM order logical: keyboard users and screen readers follow it.