@horaciogiovine/react-tiny-grid v0.1.0
React Tiny Grid
A minimalist, zero-dependency grid system for React applications. Built specifically for layout-only use cases where you need a lightweight grid without the overhead of a full CSS framework.
Why React Tiny Grid?
- ðŠķ Lightweight: Just a grid system, nothing more. Perfect when you only need layout structure
- ðĶ Zero Dependencies: No external CSS framework dependencies
- ðŊ Layout Focused: Designed for one purpose - creating responsive layouts
- ð Tiny Bundle: Minimal impact on your application's bundle size (~2KB gzipped)
- ð TypeScript Ready: Built with TypeScript for better development experience
Features
- Simple 12-column grid system
- Fluid and fixed-width containers
- Basic responsive breakpoints (xs, sm, md, lg, xl, xxl)
- TypeScript support
- Minimal SCSS modules for styling
- Essential spacing controls
- Basic responsive visibility utilities
Installation
npm install react-tiny-gridUsage
import { Container, Row, Column } from 'react-tiny-grid';
function App() {
return (
<Container>
<Row>
<Column sizeMd={6} sizeLg={4}>
Column 1
</Column>
<Column sizeMd={6} sizeLg={4}>
Column 2
</Column>
<Column sizeMd={12} sizeLg={4}>
Column 3
</Column>
</Row>
</Container>
);
}Components
Container
The root component that provides a responsive fixed-width container or a fluid-width container.
<Container fluid={false} noSpacing={false} classNames={['custom-class']}>
{/* content */}
</Container>Props:
fluid?: boolean- Makes the container full-widthnoSpacing?: boolean- Removes padding from the containerclassNames?: string[]- Additional CSS classeschildren: React.ReactNode- Container content
Row
Creates a horizontal group of columns using CSS Grid.
<Row fluid={false} noSpacing={false} classNames={['custom-class']}>
{/* columns */}
</Row>Props:
fluid?: boolean- Uses flexbox instead of grid for layoutnoSpacing?: boolean- Removes gutters between columnsclassNames?: string[]- Additional CSS classeschildren: React.ReactNode- Row contentid?: string- Optional ID for the row element
Column
Creates a column within a row, with support for different widths at different breakpoints.
<Column
size={12}
sizeXs={12}
sizeSm={6}
sizeMd={4}
sizeLg={3}
sizeXl={3}
sizeXxl={2}
fluid={false}
withVerticalGap={false}
classNames={['custom-class']}
>
{/* content */}
</Column>Props:
size?: Size- Default column width (1-12)sizeXs?: Size- Column width at xs breakpointsizeSm?: Size- Column width at sm breakpointsizeMd?: Size- Column width at md breakpointsizeLg?: Size- Column width at lg breakpointsizeXl?: Size- Column width at xl breakpointsizeXxl?: Size- Column width at xxl breakpointfluid?: boolean- Makes the column content fluidwithVerticalGap?: boolean- Adds vertical gap between nested elementsclassNames?: string[]- Additional CSS classeschildren: React.ReactNode- Column content
Breakpoints
The grid system uses these breakpoints for responsive design:
xs: 480pxsm: 576pxmd: 768pxlg: 992pxxl: 1200pxxxl: 1400px
All breakpoints work as max-width media queries (except xxl which uses min-width), meaning styles apply from that breakpoint down. For example, sizeMd={6} will apply from 768px and below.
Visibility Utilities
Control element visibility at different breakpoints using these utility classes:
<div className="hide-up-to-md">
{/* Hidden on screens smaller than md breakpoint */}
</div>
<div className="hide-from-lg">
{/* Hidden on screens larger than or equal to lg breakpoint */}
</div>Available classes:
hide-up-to-xshide-up-to-smhide-up-to-mdhide-up-to-lghide-up-to-xlhide-up-to-xxlhide-from-xshide-from-smhide-from-mdhide-from-lghide-from-xlhide-from-xxl
Spacing
The grid system uses consistent spacing variables:
- Default gutter between columns: 1.5rem
- Default vertical gap: 1rem
You can remove spacing using:
noSpacingprop on Container or Row componentswithVerticalGapprop on Column component to add vertical spacing between nested elements
License
MIT
12 months ago