Layout layoutgridcards
Glass Card Grid
Responsive grid of frosted glass cards with border highlights.
Live Preview
Glass Card Grid
Usage
Copy and paste this code into your Astro page:
astro
---
import { GlassCardGrid } from 'astro-component-kit';
---
<GlassCardGrid>Content</GlassCardGrid> ---
import { GlassCardGrid } from 'astro-component-kit';
---
<GlassCardGrid>Content</GlassCardGrid> Manual Installation
If you are not using the npm package, create a new file and paste the following code: src/components/lib/GlassCardGrid.astro:
astro
---
/**
* GlassCardGrid — A responsive grid specifically designed for card layouts with auto-fill columns.
*
* @param {string} minWidth - Minimum width of columns (default: '300px').
* @param {string} gap - Gap between items (default: '2rem').
*/
interface Props {
minWidth?: string;
gap?: string;
className?: string;
}
const { minWidth = '300px', gap = '2rem', className = '' } = Astro.props;
---
<div class={`card-grid ${className}`} style={`--min-width: ${minWidth}; --gap: ${gap};`}>
<slot />
</div>
<style>
.card-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(var(--min-width, 300px), 1fr));
gap: var(--gap, 2rem);
width: 100%;
}
</style> ---
/**
* GlassCardGrid — A responsive grid specifically designed for card layouts with auto-fill columns.
*
* @param {string} minWidth - Minimum width of columns (default: '300px').
* @param {string} gap - Gap between items (default: '2rem').
*/
interface Props {
minWidth?: string;
gap?: string;
className?: string;
}
const { minWidth = '300px', gap = '2rem', className = '' } = Astro.props;
---
<div class={`card-grid ${className}`} style={`--min-width: ${minWidth}; --gap: ${gap};`}>
<slot />
</div>
<style>
.card-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(var(--min-width, 300px), 1fr));
gap: var(--gap, 2rem);
width: 100%;
}
</style>
Quick Info
- Category
- Layout
- Filename
GlassCardGrid.astro- Dependencies
- None — pure Astro + CSS
- Tags
- layoutgridcards