Overview
TheGrid component provides a flexible, responsive grid system for laying out content. It supports two variants: an offset grid that creates a staggered visual effect on larger screens, and a small grid optimized for displaying compact items. The component automatically adapts its layout based on screen size.
Props
Determines the grid layout style:
'offset': Creates a staggered effect on desktop with odd items shifted vertically'small': Optimized for smaller items with tighter spacing- No variant: Standard two-column grid layout
Usage
Standard Grid
Offset Grid
Creates a staggered layout on desktop screens:Small Grid
Ideal for tags, icons, or compact content:Real-World Examples
Homepage Portfolio Section (src/pages/index.astro):
src/pages/work.astro):
Layout Behavior
Mobile (< 50em)
- All variants display as single column
- Standard spacing of 1rem between items
- Small variant uses 2 columns with 1.5rem gap
Desktop (≥ 50em)
Standard Grid:- Two equal columns
- 4rem gap between items
- Equal row heights
- Two columns with 4rem gap
- Odd items shifted down by 7.5rem
- Padding bottom to accommodate offset
- Last odd item in second column without offset
- Flexbox layout with wrapping
- Centered content
- 2rem gap between items
- Items have flexible basis of 20rem
- Last odd item spans both columns on mobile
Styling Features
- Automatic row height equalization with
grid-auto-rows: 1fr - Smart handling of odd-numbered last items
- Unstyled list (removes default list styling)
- Zero padding for seamless integration
- Responsive breakpoints at 50em