Documentation
Components
Grid

Grid

The Grid component is a flexible layout system that allows you to create responsive grid-based designs. It includes the Row and Col components to define the structure of your grid. The Row component is used to create horizontal groups of columns, while the Col component specifies the width and content of each column within a row. Together, these components enable you to build complex and adaptive layouts with ease.

Installation

Install the package

npm i @start-base/start-ui

Add the styles

To use the React form elements styles in a Next.js project, import the styles in your layout.tsx file.

app/layout.tsx
import "@start-base/start-ui/styles.css";

Import the component

import Grid from '@start-base/start-ui/Grid';

Usages

Grid Default

span=8
span=4
span=4
span=8

Grid With Custom Columns

span=8
span=4
span=4
span=8

Grid with Custom Padding & Gap

span=8
span=4
span=4
span=8

Grid with Independent Row & Column Gaps

span=8
span=4
span=4
span=8

Grid with Responsive Values

base=12, sm=12, md=8
base=12, sm=6, md=4
base=12, sm=6, md=4
base=12, sm=12, md=8

API

NameTypeDefaultDescription
childrenReactNodeundefinedGrid items to be displayed.
containerbooleanfalseControls whether the Grid component is a Grid container or a Grid item.
classNamestringundefinedAdditional CSS class for the root element.
spannumber | object12A value between 1 and 12 that will dictate how much horizontal space an item will use up. Accepts a number or an object of type ResponsiveGridValues which is explained below.
columnsnumber | object12A value that will be used to define the maximum span value. Accepts a number or an object of type ResponsiveGridValues which is explained below.
paddingnumber | object0Padding value for Grid container. Accepts a number or an object of type ResponsiveGridValues which is explained below.
gapnumber | object8Gap between Grid items. Accepts a number or an object of type ResponsiveGridValues which is explained below.
rowGapnumber | objectundefinedGap between the rows of Grid items. Overrides gap. Accepts a number or an object of type ResponsiveGridValues which is explained below.
columnGapnumber | objectundefinedGap between the columns of Grid items. Overrides gap. Accepts a number or an object of type ResponsiveGridValues which is explained below.
...propsHTMLAttributesAdditional HTML attributes for the root element.

ResponsiveGridValues

ResponsiveGridValues allows you to pass props depending on the viewport width.

interface ResponsiveGridValues {
  base: number;
  sm?: number; // 576px and up
  md?: number; // 768px and up
  lg?: number; // 992px and up
  xl?: number; // 1200px and up
  xxl?: number; // 1400px and up
}

base is what you would normally pass as the number to that property. Note that smaller keys cascade into larger keys if the larger keys are not specified. This means given only base and sm keys, the sm value will be used when viewport is larger than or equal to 576 pixels.