Skip to Content
Neshel-UI
Layout

Grid

A CSS grid with 1–12 equal columns, responsive column counts and item alignment.

Purpose

Grid lays items out in equal columns that line up across rows: card grids, dashboards, galleries.

Import

import.tsx
import { Grid } from "@neshel-ui/layout";

Usage

Preview: grid-columns
Preview theme
Revenue
Customers
Orders
Refunds
Visits
Conversion
grid-columns.tsx
import { Grid } from "@neshel-ui/layout";
import { Tile } from "./_tile";

const cards = ["Revenue", "Customers", "Orders", "Refunds", "Visits", "Conversion"];

/** One column on phones, two from sm, three from lg (responsive columns recipe). */
export default function GridColumns() {
  return (
    <Grid columns={{ base: 1, sm: 2, lg: 3 }} space={{ base: "2", md: "4" }}>
      {cards.map((card) => (
        <Tile key={card}>{card}</Tile>
      ))}
    </Grid>
  );
}

API

GridProps

GridProps
PropTypeDefaultDescription
alignResponsive<GridAlign>——
alignXResponsive<GridAlign>——
alignYResponsive<GridAlign>——
asLayoutElement——
asChildboolean——
columnsResponsive<GridColumns>——
refRef<HTMLElement>——
spaceResponsive<SpaceValue>——
spaceXResponsive<SpaceValue>——
spaceYResponsive<SpaceValue>——

Also accepts the props of: React DOM attributes.

GridColumns

type GridColumns = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12

GridAlign

Grid item alignment (justify-items / align-items).

type GridAlign = MainAxisAlign | "stretch"
  • columns: 1–12 (responsive), each column minmax(0, 1fr).
  • alignX → justify-items, alignY → align-items (start center end stretch).
  • spaceX/spaceY set column and row gaps separately.

Spanning and areas

Item spans, rows and template areas are not props. Use utilities (className="lg:col-span-2") or your own CSS on the children — see the dashboard recipe.

Common mistakes

  • Using Grid for a single row of items of different widths: Inline fits better.
  • Expecting auto-fit columns: the column count is explicit by design; make it responsive instead.
Edit on GitHub

On this page