Grid
Use Grid component to place items in a grid using equal width columns.
Want to skip the docs? Try our MCP Server
#
Documentation
#
#
Usage
#
Use gridTemplateColumns prop to create equally sized columns in a grid layout.
import type { ComponentPropsWithoutRef } from "react";
import { Box, Grid } from "@optiaxiom/react";
export function App() {
return (
<Grid gridTemplateColumns="3" w="full">
<DemoBox>01</DemoBox>
<DemoBox>02</DemoBox>
<DemoBox>03</DemoBox>
<DemoBox>04</DemoBox>
<DemoBox>05</DemoBox>
<DemoBox>06</DemoBox>
<DemoBox>07</DemoBox>
</Grid>
);
}
function DemoBox({ children, ...props }: ComponentPropsWithoutRef<typeof Box>) {
return (
<Box
bg="bg.avatar.purple"
display="grid"
fontFamily="mono"
fontSize="md"
fontWeight="600"
p="16"
placeItems="center"
rounded="sm"
{...props}
>
{children}
</Box>
);
}#
Gap
#
Use gap prop to control the gap between grid items.
"use client";
import type { ComponentPropsWithoutRef } from "react";
import { Box, Grid } from "@optiaxiom/react";
export function App({
gap = "16",
}: Pick<ComponentPropsWithoutRef<typeof Grid>, "gap">) {
return (
<Grid gap={gap} gridTemplateColumns="2" w="full">
<DemoBox>01</DemoBox>
<DemoBox>02</DemoBox>
<DemoBox>03</DemoBox>
<DemoBox>04</DemoBox>
</Grid>
);
}
function DemoBox({ children, ...props }: ComponentPropsWithoutRef<typeof Box>) {
return (
<Box
bg="bg.avatar.purple"
display="grid"
fontFamily="mono"
fontSize="md"
fontWeight="600"
p="16"
placeItems="center"
rounded="sm"
{...props}
>
{children}
</Box>
);
}#
Spanning columns
#
Use the gridColumn prop on children to make them span across multiple columns.
import type { ComponentPropsWithoutRef } from "react";
import { Box, Grid } from "@optiaxiom/react";
export function App() {
return (
<Grid gridTemplateColumns="3" w="full">
<DemoBox>01</DemoBox>
<DemoBox>02</DemoBox>
<DemoBox>03</DemoBox>
<DemoBox bg="bg.avatar.purple" gridColumn="2">
04
</DemoBox>
<DemoBox>05</DemoBox>
<DemoBox>06</DemoBox>
<DemoBox bg="bg.avatar.purple" gridColumn="2">
07
</DemoBox>
</Grid>
);
}
function DemoBox({ children, ...props }: ComponentPropsWithoutRef<typeof Box>) {
return (
<Box
bg="bg.avatar.neutral"
display="grid"
fontFamily="mono"
fontSize="md"
fontWeight="600"
p="16"
placeItems="center"
rounded="sm"
{...props}
>
{children}
</Box>
);
}#
Related
#
Box
Box is the base component for all our other components and provides a convenient way to use our design tokens and set element styles without having to write any custom CSS.
Flex
Use Flex component to stack items vertically or horizontally.
#
Props
#
#
Grid
#
Supports all Box props in addition to its own. Renders a <div> element.
Prop |
|---|
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read the Composition guide for more details.
|
className
|
display |
gap |
gridTemplateColumns |
#
Changelog
#
#
0.1.0
#
- Added component