Skip to Content

Grid

A brandless CSS Grid layout system. GridContainer establishes the grid; GridItem places content within it. All layout behavior is driven by CSS custom properties.

Usage

import { GridContainer, GridItem } from '@froglet/ui' <GridContainer columns={12} gap="1rem"> <GridItem columnSpan={12}>Full width</GridItem> <GridItem columnSpan={6}>Half width</GridItem> <GridItem columnSpan={6}>Half width</GridItem> <GridItem columnSpan={4}>One third</GridItem> <GridItem columnSpan={4}>One third</GridItem> <GridItem columnSpan={4}>One third</GridItem> </GridContainer>

Props

GridContainer

PropTypeDefaultDescription
childrenReactNodeGrid items to render.
columnsnumber12Number of equal-width columns.
gapCSSProperties["gap"]1remGrid gap (row and column).
autoRowsCSSProperties["gridAutoRows"]autoHeight of implicitly created rows.
autoFlowCSSProperties["gridAutoFlow"]rowDirection items are placed.
justifyContentCSSProperties["justifyContent"]startAlign grid along the inline axis.
alignContentCSSProperties["alignContent"]startAlign grid along the block axis.
classNamestringAdditional CSS classes.
refReact.Ref<HTMLDivElement>Forwarded to the underlying <div>.

GridItem

PropTypeDefaultDescription
childrenReactNodeItem content.
columnSpannumber12Number of columns to span.
rowSpannumber1Number of rows to span.
columnnumber | stringautoGrid column start line.
rownumber | stringautoGrid row start line.
justifySelfCSSProperties["justifySelf"]stretchInline-axis self-alignment.
alignSelfCSSProperties["alignSelf"]stretchBlock-axis self-alignment.
classNamestringAdditional CSS classes.
refReact.Ref<HTMLDivElement>Forwarded to the underlying <div>.

CSS Custom Properties

GridContainer

TokenDefaultDescription
--grid-container-columns12Number of equal-width columns.
--grid-container-gap1remGap between rows and columns.
--grid-container-auto-rowsautoImplicit row height.
--grid-container-auto-flowrowItem auto-placement direction.
--grid-container-justify-contentstartInline-axis alignment.
--grid-container-align-contentstartBlock-axis alignment.

GridItem

TokenDefaultDescription
--grid-item-column-span12Number of columns to span.
--grid-item-row-span1Number of rows to span.
--grid-item-columnautoColumn start line.
--grid-item-rowautoRow start line.
--grid-item-justify-selfstretchInline-axis self-alignment.
--grid-item-align-selfstretchBlock-axis self-alignment.

Responsive Use

The library does not define breakpoints. Override CSS custom properties at any breakpoint in your own stylesheet:

@media (min-width: 640px) { .my-item { --grid-item-column-span: 6; } } @media (min-width: 1024px) { .my-item { --grid-item-column-span: 4; } }
Last updated on