The Grid component is a flexible layout system that displays content items in either a standard grid layout or a Bento-style layout. It allows content editors to organize multiple components in responsive grid patterns with customizable column configurations across different device sizes.
The component supports two distinct layout modes:
- Standard Grid: A uniform grid with customizable columns per device breakpoint
- Bento Grid: A dynamic masonry-style layout with varying card sizes based on the number of items
The Grid component is used through the Optimizely CMS interface and automatically renders based on the content structure and selected display template.
- RichText: Optional header text/HTML content displayed above the grid
- Items: Collection of content components to display in the grid layout
The layout is automatically determined by the displayTemplateKey:
GridBentoStyles: Renders the Bento layoutGridStyles(default): Renders the standard grid layout
- Columns on Desktop: 1-4 columns (default: 3)
- Columns on Tablet: 1-4 columns (default: 2)
- Columns on Mobile: 1-4 columns (default: 1)
- No configurable options - uses dynamic patterns based on item count
[Placeholder for Grid component screenshot showing both standard and Bento layouts]
Grid.astro- Main component that routes to Standard or Bento layoutsGridStandard.astro- Standard responsive grid implementationGridBento.astro- Bento masonry-style grid implementationGridStyles.ts- Style conversion utilities for standard gridGridBentoHelper.ts- Layout pattern utilities for Bento gridgrid.graphql- GraphQL fragment for data fetchingGridStyles.opti-style.json- CMS style configuration for standard gridGridBentoStyles.opti-style.json- CMS style configuration for Bento grid
- The component automatically prevents infinite nesting by excluding Grid components from the
AllComponentsExceptGridfragment - Bento layout patterns are predefined for up to 12 items, with a repeating pattern for larger collections
- Both layouts are fully responsive and work with any child component type
- The standard grid uses CSS Grid with gap spacing, while Bento uses a 12-column layout system