Grid Template Columns
Use gridTemplateColumns prop to create equally sized columns in a grid layout.
Name | Styles |
|---|---|
1 | |
2 | |
3 | |
4 |
#
Documentation
#
#
Usage
#
01
02
03
04
05
06
07
import type { ComponentPropsWithoutRef } from "react";
import { Box, Grid } from "@optiaxiom/react";
export function App({
gridTemplateColumns = "3",
}: Pick<ComponentPropsWithoutRef<typeof Grid>, "gridTemplateColumns">) {
return (
<Grid gridTemplateColumns={gridTemplateColumns} 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>
);
}#
Responsive
#
import type { ComponentPropsWithoutRef } from "react";
import { Box, Grid } from "@optiaxiom/react";
export function App() {
return (
<Grid gridTemplateColumns={["1", "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>
);
}Last updated on