Column count, or a count per breakpoint ({ base: 1, md: 3 }); ignored with autoFit / autoFill.
rows
1 | 2 | 3 | 4 | 5 | 6
—
Row count.
gap
0 | 1 | 2 | 3 | 4 | 5 | 6 | 8 | 10 | 12 | 16
4
Gap token (stackGap) between rows and columns.
colGap
0 | 1 | 2 | 3 | 4 | 5 | 6 | 8 | 10 | 12 | 16
—
Gap between columns; with rowGap, it replaces gap.
rowGap
0 | 1 | 2 | 3 | 4 | 5 | 6 | 8 | 10 | 12 | 16
—
Gap between rows; with colGap, it replaces gap.
autoFit
boolean
false
As many columns as fit, empty tracks collapsed.
autoFill
boolean
false
As many columns as fit, empty tracks kept.
minColWidth
string
'16rem'
Narrowest column with autoFit / autoFill (any CSS length).
align
'start' | 'center' | 'end' | 'stretch'
—
Block-axis alignment of the items.
justify
'start' | 'center' | 'end' | 'stretch'
—
Inline-axis alignment of the items.
as
keyof React.JSX.IntrinsicElements
—
Element to render.
surface
'pixel' | 'linear'
—
Surface override; defaults to the nearest provider.
Also takes the native attributes and event handlers of <div> (HTMLAttributes<HTMLDivElement>).
ref points to <div>.
Accessibility
WCAG target: 2.1 AA
Renders as <div> by default; inherits semantics from the element provided via as (e.g. ul, section). Authors are responsible for the semantic role of grid children.
Usage
import React from 'react';
import { PixelGrid } from '@pxlkit/ui-kit';
function Cell({ children }: { children: React.ReactNode }) {
return (
<div className="border border-retro-border bg-retro-surface p-3 text-sm text-retro-text">
{children}
</div>
);
}
export function Default() {
return (
<PixelGrid cols={3} gap={4}>
<Cell>One</Cell>
<Cell>Two</Cell>
<Cell>Three</Cell>
<Cell>Four</Cell>
<Cell>Five</Cell>
<Cell>Six</Cell>
</PixelGrid>
);
}
Examples
Default
import React from 'react';
import { PixelGrid } from '@pxlkit/ui-kit';
function Cell({ children }: { children: React.ReactNode }) {
return (
<div className="border border-retro-border bg-retro-surface p-3 text-sm text-retro-text">
{children}
</div>
);
}
export function Default() {
return (
<PixelGrid cols={3} gap={4}>
<Cell>One</Cell>
<Cell>Two</Cell>
<Cell>Three</Cell>
<Cell>Four</Cell>
<Cell>Five</Cell>
<Cell>Six</Cell>
</PixelGrid>
);
}