# Grid Span

Applies responsive row and column spans to a grid child.

`GridSpan` is the responsive spanning companion to Grid. It lets one child occupy different numbers of columns or rows without taking responsibility for explicit starting lines or alignment.

```tsx
import { Center, Grid, GridSpan, Text } from "@zentara-co/zenos-ui";
import { type ReactNode } from "react";

function GridDemoTile({ children, className }: { children: ReactNode; className?: string }) {
  return (
    <Center
      minHeight="20"
      padding="3"
      className={`rounded-lg border border-border bg-background-neutral-card ${className ?? ""}`}
    >
      <Text size="s" weight="bold" align="center">
        {children}
      </Text>
    </Center>
  );
}

function GridSpanExample() {
  return (
    <Grid columns={{ base: 1, md: 6 }} gap="4" className="w-full">
      <GridSpan columns={{ base: 1, md: 4 }}>
        <GridDemoTile>Main content · 4 of 6 columns</GridDemoTile>
      </GridSpan>
      <GridSpan columns={{ base: 1, md: 2 }}>
        <GridDemoTile>Sidebar · 2 of 6 columns</GridDemoTile>
      </GridSpan>
      <GridSpan columns="full">
        <GridDemoTile>Full-width footer</GridDemoTile>
      </GridSpan>
    </Grid>
  );
}
```

## Import

```tsx
import { Grid, GridSpan } from "@zentara-co/zenos-ui";
```

## Responsive spans

Both `columns` and `rows` accept a direct value or breakpoint object. Use `full` to cover the complete explicit grid and `auto` to return to automatic spanning.

```tsx
<Grid columns={{ base: 1, md: 6 }} gap="4">
  <GridSpan columns={{ base: 1, md: 4 }}>Main</GridSpan>
  <GridSpan columns={{ base: 1, md: 2 }}>Aside</GridSpan>
  <GridSpan columns="full">Footer</GridSpan>
</Grid>
```

```tsx
import { Center, Grid, GridSpan, Text } from "@zentara-co/zenos-ui";
import { type ReactNode } from "react";

function GridDemoTile({ children, className }: { children: ReactNode; className?: string }) {
  return (
    <Center
      minHeight="20"
      padding="3"
      className={`rounded-lg border border-border bg-background-neutral-card ${className ?? ""}`}
    >
      <Text size="s" weight="bold" align="center">
        {children}
      </Text>
    </Center>
  );
}

function GridSpanRowsExample() {
  return (
    <Grid columns={3} rows={3} gap="3" className="w-full">
      <GridSpan columns={2} rows={{ base: 1, md: 2 }}>
        <GridDemoTile className="h-full">Responsive row span</GridDemoTile>
      </GridSpan>
      <GridSpan columns={1} rows={1}>
        <GridDemoTile>One track</GridDemoTile>
      </GridSpan>
      <GridSpan columns={1} rows={2}>
        <GridDemoTile className="h-full">Two rows</GridDemoTile>
      </GridSpan>
      <GridSpan columns={2} rows={1}>
        <GridDemoTile>Two columns</GridDemoTile>
      </GridSpan>
    </Grid>
  );
}
```

## GridSpan or GridItem

Use GridSpan when spans change responsively and automatic placement should choose the start position. Use GridItem when the child needs a fixed starting row or column, fixed spans, or self-alignment.

GridSpan is polymorphic and forwards native props and refs to the selected element.

## API

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| as | ElementType | div | Rendered semantic element. |
| columns | Responsive<1–12 \| full \| auto> | — | Responsive column span. |
| rows | Responsive<1–12 \| full \| auto> | — | Responsive row span. |
| native props | React.HTMLAttributes<HTMLElement> | — | Forwards native attributes, events, aria-*, data-*, className, style, and ref. |

Unless narrowed above, each DOM-rendering part also accepts its underlying native or Base UI props, including className, style, aria-*, and data-*.

## Accessibility

Spans change visual size without changing semantics. Keep the source order logical and avoid using large spans to imply heading or landmark importance. Choose `as` based on the content itself.

Source: https://zenos-ui.pages.dev/layout/grid-span/