Skip to content
Tennantite
中文
Documentation

Grid

Pure layout grid for item slots with configurable columns, rows and gap.

Install

CLI copy

$npx shadcn add @tennantite/grid

npm install

$pnpm add @tennantite/ui

npm installs the compiled package; use the CLI copy above to adapt the source.

Usage

npm import

import { Grid } from "@tennantite/ui";

CLI copy import

import { Grid } from "@/components/tennantite/grid";
import { Icon } from "../icon/index";
import { Slot } from "../slot/index";
import { Grid } from "./index";

export function GridDemo() {
  return (
    <div className="mc-tex-panel inline-block p-6">
      <Grid columns={9}>
        {Array.from({ length: 27 }, (_, index) => (
          <Slot key={index} selected={index === 4}>
            {index === 4 ? <Icon name="diamond" /> : null}
          </Slot>
        ))}
      </Grid>
    </div>
  );
}

API Reference

PropTypeDefaultDescription
cellSizenumber18Cell size in GUI px (default 18 — vanilla slot).
columnsnumber—Number of columns (spec §5 #2).
gapnumber0Gap between cells in GUI px (default 0 — vanilla slots are adjacent).
rowsnumber—Number of rows (auto when omitted).

Source

packages/ui/src/containers/grid/index.tsx

The npm package keeps the source tree, so you can copy and adapt it directly.