Getting Started
Components
Special Effects
Animations
Text Animations
Backgrounds
Bento grid is a layout used to showcase the features of a product in a simple and elegant way.
@lucide/svelte
bento-grid.svelte
<script lang="ts"> import { BentoCard, BentoGrid } from "$lib/components/magic/bento-grid/index.js";
// Icons import FileTextIcon from "@lucide/svelte/icons/file-text"; import InputIcon from "@lucide/svelte/icons/file-input"; import GlobeIcon from "@lucide/svelte/icons/globe"; import CalendarIcon from "@lucide/svelte/icons/calendar"; import BellIcon from "@lucide/svelte/icons/bell";
import type { Snippet } from "svelte";
type Feature = { Icon: typeof FileTextIcon; name: string; background: Snippet; description: string; href: string; cta: string; class: string; iconClass?: string; };
let features: Feature[] = [ { Icon: FileTextIcon, name: "Save your files", background: bg, description: "We automatically save your files as you type.", href: "/", cta: "Learn more", class: "lg:row-start-1 lg:row-end-4 lg:col-start-2 lg:col-end-3", iconClass: "stroke-[1.4]", }, { Icon: InputIcon, name: "Full text search", background: bg, description: "Search through all your files in one place.", href: "/", cta: "Learn more", class: "lg:col-start-1 lg:col-end-2 lg:row-start-1 lg:row-end-3", iconClass: "stroke-[1.4]", }, { Icon: GlobeIcon, name: "Multilingual", background: bg, description: "Supports 100+ languages and counting.", href: "/", cta: "Learn more", class: "lg:col-start-1 lg:col-end-2 lg:row-start-3 lg:row-end-4", iconClass: "stroke-[1.4]", }, { Icon: CalendarIcon, name: "Calendar", background: bg, description: "Use the calendar to filter your files by date.", href: "/", cta: "Learn more", class: "lg:col-start-3 lg:col-end-3 lg:row-start-1 lg:row-end-2", iconClass: "stroke-[1.4]", }, { Icon: BellIcon, name: "Notifications", background: bg, description: "Get notified when someone shares a file or mentions you in a comment.", href: "/", cta: "Learn more", class: "lg:col-start-3 lg:col-end-3 lg:row-start-2 lg:row-end-4", iconClass: "stroke-[1.4]", }, ];</script>
<!-- background -->{#snippet bg()} <img src="" alt="demo" class="absolute -top-20 -right-20 opacity-60" />{/snippet}
<BentoGrid class="lg:grid-rows-3"> {#each features as feature} <BentoCard {...feature} /> {/each}</BentoGrid>Installation
pnpm dlx shadcn-svelte@latest add https://sv-animations.vercel.app/r/bento-grid.json
Install dependencies
Install the required packages for this component:
pnpm add @lucide/svelte
Copy the Source Code
Copy and paste the following code into your project:
bento-grid.svelte
<script lang="ts"> import { cn } from "#lib/utils.js"; import type { Snippet } from "svelte"; import type { ClassValue, HTMLAttributes } from "svelte/elements";
interface BentoGridProps extends HTMLAttributes<HTMLDivElement> { children: Snippet; class?: ClassValue; }
let { children, class: className, ...props }: BentoGridProps = $props();</script>
<div class={cn("grid w-full auto-rows-[22rem] grid-cols-3 gap-4", className)} {...props}> {@render children()}</div> bento-card.svelte
<script lang="ts"> import type { Snippet } from "svelte"; import type { ClassValue, HTMLAttributes } from "svelte/elements"; import type { Component } from "svelte";
import { cn } from "#lib/utils.js"; import Button from "#lib/components/ui/button/button.svelte"; import { ArrowRightIcon } from "@lucide/svelte";
interface BentoCardProps extends HTMLAttributes<HTMLDivElement> { name: string; class?: ClassValue; background: Snippet; Icon: Component<any>; iconClass?: string; description: string; href: string; cta: string; }
let { name, class: className, background, Icon, iconClass = "", description, href, cta, ...props }: BentoCardProps = $props();</script>
<div class={cn( "group relative col-span-3 flex flex-col justify-between overflow-hidden rounded-xl", // light styles "bg-background [box-shadow:0_0_0_1px_rgba(0,0,0,.03),0_2px_4px_rgba(0,0,0,.05),0_12px_24px_rgba(0,0,0,.05)]", // dark styles "dark:bg-background transform-gpu dark:[box-shadow:0_-20px_80px_-20px_#ffffff1f_inset] dark:[border:1px_solid_rgba(255,255,255,.1)]", className )} {...props}> <div>{@render background()}</div> <div class="p-4"> <div class="pointer-events-none z-10 flex transform-gpu flex-col gap-1 transition-all duration-300 lg:group-hover:-translate-y-10" > <Icon class={cn( "h-12 w-12 origin-left transform-gpu text-neutral-700 transition-all duration-300 ease-in-out group-hover:scale-75", iconClass )} /> <h3 class="text-xl font-semibold text-neutral-700 dark:text-neutral-300"> {name} </h3> <p class="max-w-lg text-neutral-400">{description}</p> </div> <div class={cn( "pointer-events-none flex w-full translate-y-0 transform-gpu flex-row items-center transition-all duration-300 group-hover:translate-y-0 group-hover:opacity-100 lg:hidden" )} > <Button variant="link" size="sm" class="pointer-events-auto p-0"> <a {href}> {cta} <ArrowRightIcon class="ms-2 h-4 w-4 rtl:rotate-180" /> </a> </Button> </div> </div> <div class={cn( "pointer-events-none absolute bottom-0 hidden w-full translate-y-10 transform-gpu flex-row items-center p-4 opacity-0 transition-all duration-300 group-hover:translate-y-0 group-hover:opacity-100 lg:flex" )} > <Button {href} variant="link" size="sm" class="pointer-events-auto p-0"> {cta} <ArrowRightIcon class="ms-2 h-4 w-4 rtl:rotate-180" /> </Button> </div> <div class="pointer-events-none absolute inset-0 transform-gpu transition-all duration-300 group-hover:bg-black/3 group-hover:dark:bg-neutral-800/10" ></div></div> index.ts
import BentoCard from "./bento-card.svelte";import BentoGrid from "./bento-grid.svelte";export { BentoCard, BentoGrid };Folder Structure
Folder Structure
src/└── lib/ └── components/ └── magic/ └── bento-grid/ ├── bento-grid.svelte ├── bento-card.svelte └── index.tsInstall and integrate the Svelte component documented below.https://sv-animations.vercel.app/magic/docs/components/bento-grid/llms.txt
Follow the guide's installation and usage instructions.Match the project's existing structure, imports, and styles.Keep changes scoped to the component and verify it works.Reply with a short bullet list of completed changes.Usage
<script lang="ts"> import BoxIcon from "@lucide/svelte/icons/box"; import { BentoCard, BentoGrid } from "#lib/components/magic/bento-grid/index.js";</script>
{#snippet background()} <div class="absolute inset-0 bg-muted"></div>{/snippet}
<BentoGrid> <BentoCard name="Analytics" description="Track your most important metrics." href="/analytics" cta="View analytics" Icon={BoxIcon} {background} /></BentoGrid>Props
Bento Grid
Bento grid component
| Name | Type | Default | Description |
|---|---|---|---|
class | ClassValue | "" | Additional CSS classes to apply |
children | Snippet | | The content to be displayed inside the grid |
Bento Card
| Name | Type | Default | Description |
|---|---|---|---|
name | string | | The name of the card, displayed as the title |
class | ClassValue | "" | Additional CSS classes to apply |
background | Snippet | | The background of the card, can be a color or an image |
Icon | Component<any> | | The icon to be displayed on the card, passed as a Svelte component |
iconClass | string | "" | |
description | string | | A brief description of the card's content |
href | string | | The URL to navigate to when the card is clicked |
cta | string | | The call-to-action text displayed on the card |