A CSS-based masonry layout for items of varying heights.
Component preview not available for: masonry-grid
masonry-grid
Ensure the filename matches MasonryGrid.astro
MasonryGrid.astro
Copy the full block below to use this component with its imports.
--- import { MasonryLayout } from 'astro-component-kit'; --- <MasonryGrid>Content</MasonryGrid>
If you are not using the npm package, create a new file src/components/lib/MasonryLayout.astro and paste the following code:
src/components/lib/MasonryLayout.astro
--- --- <div class="masonry"><slot /></div> <style> .masonry { columns: 3 250px; column-gap: 1.5rem; } .masonry :global(> *) { break-inside: avoid; margin-bottom: 1.5rem; display: block; } </style>
MasonryLayout.astro