Grid

A CSS Grid container component with props for columns, rows, and gap. Use with GridItem for advanced spanning and positioning.

Anatomy

<script>
  import { Grid, GridItem } from "@saas-ui/svelte/layout/grid";
</script>

<Grid columns={3} gap={4}>
  <GridItem>Item 1</GridItem>
  <GridItem colSpan={2}>Spans 2 columns</GridItem>
  <GridItem>Item 3</GridItem>
</Grid>

Examples

Basic Accessibility

Basic grid layout with configurable number of equal-width columns and gap.

Custom Gap Accessibility

Use gapX and gapY to set different horizontal and vertical gaps between grid items.

Spanning Accessibility

Use GridItem with colSpan and rowSpan props to create items that span multiple columns or rows.

Props

Prop Type Default Description
columns number - The number of columns in the grid template.
rows number - The number of rows in the grid template.
gap number 4 The gap between grid items.
gapX number - The column gap between grid items.
gapY number - The row gap between grid items.
children any - The content to be rendered inside the component.
class text - Additional CSS classes to apply.