Animated Image Grid

A stunning, fluid CSS grid layout that beautifully reflows items when they are dynamically added or removed. It leverages cutting-edge CSS container queries (container-type), math functions (round(), mod()), and @starting-style to orchestrate complex entrance animations purely through CSS!

Showcase

Grid image 0
Grid image 1
Grid image 2
Grid image 3
Grid image 4
Grid image 5
Grid image 6
Grid image 7
Grid image 8
Grid image 9
Grid image 10
Grid image 11
Grid image 12
Grid image 13
Grid image 14
Grid image 15
Grid image 16
Grid image 17

Note: This component uses modern CSS functions (round(), mod(), @starting-style). Ensure your target audience is using reasonably modern browsers (Chrome 111+, Safari 16.4+, Firefox 113+).

Installation

npx shadcn-extras@latest add animated-image-grid

Usage


npx shadcn-extras@latest add animated-image-grid


import { AnimatedImageGrid } from '@/components/core/animated-image-grid';
const MOCK_ITEMS = [
{ id: 1, src: 'https://i.pravatar.cc/150?img=1' },
{ id: 2, src: 'https://i.pravatar.cc/150?img=2' },
];
export function Example() {
return <AnimatedImageGrid items={MOCK_ITEMS} gap='10px' size='130px' />;
}

Props

PropTypeDescription
itemsAnimatedImageGridItem[]An array of objects containing id and src properties.
gapstringThe gap between grid items (default: 10px).
sizestringThe size of the square grid items (default: 130px).
variantstringThe visual style variant ('default', 'circle', 'polaroid', 'minimal').
itemClassNamestringCustom Tailwind classes for the item wrapper div.
imageClassNamestringCustom Tailwind classes for the image element itself.