Aspect Grid
Equal columns where every child has the same aspect ratio.
<arc-aspect-grid>Overview
AspectGrid lays its children out in equal-width columns and gives every child the same aspect ratio. Use it when every item should be the same size: photo galleries, team portraits, video thumbnails, product cards.
For items of different heights that should pack tightly, use Masonry. For dashboard layouts with named regions, use DashboardGrid.
Guidelines
Do
- Use ratio="1/1" for avatars, product squares and icons
- Use ratio="16/9" for video thumbnails and wide images
- Use ratio="4/3" for photos and other landscape images
- Set object-fit: cover on images so they fill their cells
Don't
- Don't use it for content of different heights. Use Masonry
- Don't mix ratios in one grid. Use separate grids
- Don't put long text in a cell. It overflows and gets clipped
Features
- `columns` sets the number of equal-width columns
- `ratio` takes 1/1 (square), 16/9 (widescreen) or 4/3 (classic)
- `gap` takes sm, md or lg, mapped to the spacing tokens
- Each child gets a 1px border, `--radius-md` corners and `overflow: hidden`
- Layout is CSS only. There is no column count per breakpoint, so a responsive grid means changing `columns` yourself
Preview
1
2
3
4
5
6
Usage
<arc-aspect-grid columns="3" ratio="1/1" gap="md">
<img src="/photo-1.jpg" alt="Photo 1" style="object-fit:cover;width:100%;height:100%">
<img src="/photo-2.jpg" alt="Photo 2" style="object-fit:cover;width:100%;height:100%">
<img src="/photo-3.jpg" alt="Photo 3" style="object-fit:cover;width:100%;height:100%">
<img src="/photo-4.jpg" alt="Photo 4" style="object-fit:cover;width:100%;height:100%">
<img src="/photo-5.jpg" alt="Photo 5" style="object-fit:cover;width:100%;height:100%">
<img src="/photo-6.jpg" alt="Photo 6" style="object-fit:cover;width:100%;height:100%">
</arc-aspect-grid>import { AspectGrid } from '@arclux/arc-ui-react';
function PhotoGallery() {
return (
<AspectGrid columns={3} ratio="1/1" gap="md">
<img src="/photo-1.jpg" alt="Photo 1" style={{ objectFit: 'cover', width: '100%', height: '100%' }} />
<img src="/photo-2.jpg" alt="Photo 2" style={{ objectFit: 'cover', width: '100%', height: '100%' }} />
<img src="/photo-3.jpg" alt="Photo 3" style={{ objectFit: 'cover', width: '100%', height: '100%' }} />
</AspectGrid>
);
}<script setup>
import { AspectGrid } from '@arclux/arc-ui-vue';
</script>
<template>
<AspectGrid :columns="3" ratio="1/1" gap="md">
<img src="/photo-1.jpg" alt="Photo 1" style="object-fit:cover;width:100%;height:100%">
<img src="/photo-2.jpg" alt="Photo 2" style="object-fit:cover;width:100%;height:100%">
<img src="/photo-3.jpg" alt="Photo 3" style="object-fit:cover;width:100%;height:100%">
</AspectGrid>
</template><script>
import { AspectGrid } from '@arclux/arc-ui-svelte';
</script>
<AspectGrid columns={3} ratio="1/1" gap="md">
<img src="/photo-1.jpg" alt="Photo 1" style="object-fit:cover;width:100%;height:100%">
<img src="/photo-2.jpg" alt="Photo 2" style="object-fit:cover;width:100%;height:100%">
<img src="/photo-3.jpg" alt="Photo 3" style="object-fit:cover;width:100%;height:100%">
</AspectGrid>import { Component } from '@angular/core';
import { AspectGrid } from '@arclux/arc-ui-angular';
@Component({
imports: [AspectGrid],
template: `
<arc-aspect-grid [columns]="3" ratio="1/1" gap="md">
<img src="/photo-1.jpg" alt="Photo 1" style="object-fit:cover;width:100%;height:100%">
<img src="/photo-2.jpg" alt="Photo 2" style="object-fit:cover;width:100%;height:100%">
<img src="/photo-3.jpg" alt="Photo 3" style="object-fit:cover;width:100%;height:100%">
</arc-aspect-grid>
`,
})
export class GalleryComponent {}import { AspectGrid } from '@arclux/arc-ui-solid';
function PhotoGallery() {
return (
<AspectGrid columns={3} ratio="1/1" gap="md">
<img src="/photo-1.jpg" alt="Photo 1" style={{ 'object-fit': 'cover', width: '100%', height: '100%' }} />
<img src="/photo-2.jpg" alt="Photo 2" style={{ 'object-fit': 'cover', width: '100%', height: '100%' }} />
<img src="/photo-3.jpg" alt="Photo 3" style={{ 'object-fit': 'cover', width: '100%', height: '100%' }} />
</AspectGrid>
);
}import { AspectGrid } from '@arclux/arc-ui-preact';
function PhotoGallery() {
return (
<AspectGrid columns={3} ratio="1/1" gap="md">
<img src="/photo-1.jpg" alt="Photo 1" style={{ objectFit: 'cover', width: '100%', height: '100%' }} />
<img src="/photo-2.jpg" alt="Photo 2" style={{ objectFit: 'cover', width: '100%', height: '100%' }} />
<img src="/photo-3.jpg" alt="Photo 3" style={{ objectFit: 'cover', width: '100%', height: '100%' }} />
</AspectGrid>
);
}<!-- Auto-generated by @arclux/prism — do not edit manually -->
<!-- arc-aspect-grid — requires aspect-grid.css + base.css (or arc-ui.css) -->
<div class="arc-aspect-grid">
<div class="grid">
AspectGrid
</div>
</div><!-- Auto-generated by @arclux/prism — do not edit manually -->
<!-- arc-aspect-grid — self-contained, no external CSS needed -->
<div class="arc-aspect-grid" style="display: block">
<div style="display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px">
AspectGrid
</div>
</div>API
columnsnumber3- Number of columns in the grid. Each column is equal width (1fr).
ratio'1/1' | '16/9' | '4/3''1/1'- Aspect ratio applied to every cell. 1/1 for squares, 16/9 for widescreen, 4/3 for classic landscape.
gap'sm' | 'md' | 'lg''md'- Spacing between grid cells, mapped to design system spacing tokens (--space-sm, --space-md, --space-lg).