Grid
Grid provides a declarative CSS grid container with props for columns, rows, gap, alignment, and auto-flow.
Basic Usage
1
2
3
4
5
6
import { Grid } from "@paramanu/primitives-react"
export default function App() {return ( <Grid columns={3} gap="4"> <div>1</div> <div>2</div> <div>3</div> <div>4</div> <div>5</div> <div>6</div> </Grid>)}<div class="pm-grid pm-grid--cols-3 pm-grid--gap-4"><div style="background: #e2e8f0; padding: 16px; text-align: center;">1</div><div style="background: #e2e8f0; padding: 16px; text-align: center;">2</div><div style="background: #e2e8f0; padding: 16px; text-align: center;">3</div><div style="background: #e2e8f0; padding: 16px; text-align: center;">4</div><div style="background: #e2e8f0; padding: 16px; text-align: center;">5</div><div style="background: #e2e8f0; padding: 16px; text-align: center;">6</div></div>Best Practices
- Use Grid for two-dimensional layouts. For one-dimensional, use Flex or Stack.
- Use Sgrid for auto-fill responsive grids.
React Props
| Prop | Type | Default | Description |
|---|---|---|---|
columns | 1-12 | "none" | — | Grid columns |
rows | 1-6 | "none" | — | Grid rows |
gap | SpacingScale | — | Gap |
rowGap | SpacingScale | — | Row gap |
columnGap | SpacingScale | — | Column gap |
align | FlexAlign | — | Align items |
justify | FlexJustify | — | Justify content |
inline | boolean | false | Inline grid |
flow | GridFlow | — | Auto-flow |
CSS Classes
| Class | Purpose |
|---|---|
pm-grid | Base |
pm-grid--cols-{n} | Columns |
pm-grid--rows-{n} | Rows |
pm-grid--gap-{scale} | Gap |
pm-grid--inline | Inline grid |