Expandable Bento Grid
A responsive bento grid layout with expandable cards using Framer Motion layout animations.
Repository
Version Control
Connect
Team Communication
Reach
Audience Engagement
Analytics
Data Insights
Installation
1. Install Dependencies
2. Run the CLI command
npx shadcn@latest add "https://vengeance-ui.vercel.app/r/undefined.json"3. Manual Installation
Add the hook
Create a file at src/hooks/use-outside-click.ts and add the following code:
Add the component
Create a file at src/components/ui/expandable-bento-grid.tsx and copy the source code:
Usage
import ExpandableBentoGrid from "@/components/ui/expandable-bento-grid"
import { Github, Slack } from 'lucide-react'
// ... items definition
export default function MyPage() {
return (
<div className="p-10">
<ExpandableBentoGrid items={items} />
</div>
)
}Props
BentoGridProps
| Prop | Type | Description |
|---|---|---|
items | BentoItem[] | Array of items to display in the grid. |
BentoItem
| Prop | Type | Description |
|---|---|---|
id | string | number | Unique identifier for the item. |
title | string | Title of the card. |
subtitle | string | Subtitle text. |
description | string | Short description text. |
content | React.ReactNode | Content to display when expanded. |
icon | React.ReactNode | Icon to display. |
className | string | Optional CSS class. |
Features
- Smooth Expansion: Cards expand smoothly using Framer Motion layout transitions.
- Shared Layout: Elements transition seamlessly between the grid and the expanded view.
- Backdrop Blur: Adds a backdrop when a card is active.
- Accessibility: Handles Escape key and outside clicks to close the expanded view.
- Responsive: Adapts to different screen sizes.