@molecule/app-card-grid-svelte

Feature · card-grid · App (browser) · v1.1.2 · Apache-2.0

Responsive Svelte card grid and bento-grid layouts

npm install @molecule/app-card-grid-svelte

npm · Source on GitHub

How it works

@molecule/app-card-grid-svelte is a ready-made card-grid feature for the app (browser) side. It composes the core interfaces it needs, so it works with whichever providers your app has bonded.

<script lang="ts">
  import { BentoGrid, CardGrid } from '@molecule/app-card-grid-svelte'

  const items = [
    { id: 'hero', content: hero, colSpan: 8, rowSpan: 2 },
    { id: 'stats', content: stats, colSpan: 4 },
  ]
</script>

<CardGrid columns={3} gap="md">
  <ProductCard product={products[0]} />
  <ProductCard product={products[1]} />
  <ProductCard product={products[2]} />
</CardGrid>

<BentoGrid {items} />

Works with: @molecule/app-svelte, @molecule/app-ui, @molecule/app-ui-svelte

Reference

Svelte card-grid and bento-grid layouts.

Exports:

  • CardGrid — responsive grid with configurable column count.
  • BentoGrid — col/row-span or named-areas layout for mixed-size cards.

This is the Svelte counterpart of @molecule/app-card-grid-react: the same exports, the same props (React names), and the same DOM for the same input.

Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit src/index.ts JSDoc, not this file.

Quick Start

<script lang="ts">
  import { BentoGrid, CardGrid } from '@molecule/app-card-grid-svelte'

  const items = [
    { id: 'hero', content: hero, colSpan: 8, rowSpan: 2 },
    { id: 'stats', content: stats, colSpan: 4 },
  ]
</script>

<CardGrid columns={3} gap="md">
  <ProductCard product={products[0]} />
  <ProductCard product={products[1]} />
  <ProductCard product={products[2]} />
</CardGrid>

<BentoGrid {items} />

Type

feature

Installation

npm install @molecule/app-card-grid-svelte @molecule/app-svelte @molecule/app-ui @molecule/app-ui-svelte svelte

API

Interfaces

BentoItem

Data descriptor for a single cell in a BentoGrid layout.

interface BentoItem {
  /** Unique item identifier (Svelte's keyed `{#each}` identity). */
  id: string
  /** Card content (React's `ReactNode`: text, or a snippet rendering a node). */
  content: Snippet | string | number
  /** CSS grid-column-span (1-12). Defaults to 4. */
  colSpan?: number
  /** CSS grid-row-span (1-6). Defaults to 1. */
  rowSpan?: number
  /** Named grid-area when using `areas` layout. */
  area?: string
}

BentoGridProps

Props for BentoGrid.

interface BentoGridProps {
  /** Items to render. */
  items: BentoItem[]
  /**
   * Optional `grid-template-areas` string (e.g. `'a a b' 'c d d'`). When
   * provided, each `BentoItem.area` must match a token in the template.
   */
  areas?: string
  /** Default column count when `areas` is absent. Defaults to 12. */
  columns?: number
  /** Gap between items. */
  gap?: 'xs' | 'sm' | 'md' | 'lg'
  /** Extra classes. */
  className?: string
}

CardGridProps

Props for CardGrid.

interface CardGridProps {
  /** Cards — the default content. */
  children?: Snippet
  /** Column count at the md+ breakpoint. 1–6. Defaults to 3. */
  columns?: 1 | 2 | 3 | 4 | 5 | 6
  /** Gap between cards. */
  gap?: 'xs' | 'sm' | 'md' | 'lg'
  /** Extra classes. */
  className?: string
}

Constants

BentoGrid

const BentoGrid: LegacyComponentType

CardGrid

const CardGrid: LegacyComponentType

Injection Notes

Requirements

Peer dependencies:

  • @molecule/app-svelte ^3.5.0 || ^4.0.0
  • @molecule/app-ui ^1.0.1
  • @molecule/app-ui-svelte ^1.1.0
  • svelte ^5.0.0

Runtime Dependencies

  • @molecule/app-svelte
  • @molecule/app-ui
  • @molecule/app-ui-svelte
  • svelte

CardGrid collapses to one column on narrow viewports and grows to columns (1–6) at the md+ breakpoint via the ClassMap grid. In BentoGrid, span mode uses a columns-wide grid (default 12) with per-item colSpan/rowSpan; passing areas switches to named grid-template-areas — then every item must set a matching area token or it falls out of the template. Node values are snippets: a BentoItem.content (and CardGrid's children) is a Snippet or text.