@molecule/app-card-grid-vue
Feature · card-grid · App (browser) · v1.1.1 · Apache-2.0
Responsive Vue card grid and bento-grid layouts
npm install @molecule/app-card-grid-vueHow it works
@molecule/app-card-grid-vue 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.
import { createApp, defineComponent, h } from 'vue'
import { BentoGrid, CardGrid } from '@molecule/app-card-grid-vue'
const Grids = defineComponent({
setup() {
return () =>
h('div', [
h(
CardGrid,
{ columns: 3, gap: 'md' },
{
default: () => [
h(ProductCard, { product: products[0] }),
h(ProductCard, { product: products[1] }),
h(ProductCard, { product: products[2] }),
],
},
),
h(BentoGrid, {
items: [
{ id: 'hero', content: h(HeroCard), colSpan: 8, rowSpan: 2 },
{ id: 'stats', content: h(StatsCard), colSpan: 4 },
],
}),
])
},
})
createApp(Grids).mount('#app')Works with: @molecule/app-ui, @molecule/app-ui-vue, @molecule/app-vue
Reference
Vue 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 Vue 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.tsJSDoc, not this file.
Quick Start
import { createApp, defineComponent, h } from 'vue'
import { BentoGrid, CardGrid } from '@molecule/app-card-grid-vue'
const Grids = defineComponent({
setup() {
return () =>
h('div', [
h(
CardGrid,
{ columns: 3, gap: 'md' },
{
default: () => [
h(ProductCard, { product: products[0] }),
h(ProductCard, { product: products[1] }),
h(ProductCard, { product: products[2] }),
],
},
),
h(BentoGrid, {
items: [
{ id: 'hero', content: h(HeroCard), colSpan: 8, rowSpan: 2 },
{ id: 'stats', content: h(StatsCard), colSpan: 4 },
],
}),
])
},
})
createApp(Grids).mount('#app')
Type
feature
Installation
npm install @molecule/app-card-grid-vue @molecule/app-ui @molecule/app-ui-vue @molecule/app-vue vue
API
Interfaces
BentoItem
Data descriptor for a single cell in a BentoGrid layout.
interface BentoItem {
/** Unique item identifier (Vue key). */
id: string
/** Card content (React's `ReactNode`: a VNode or text). */
content: VNodeChild
/** 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 slot (also accepted as a `children` prop). */
children?: VNodeChild
/** 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
Bento-style grid — items span multiple cells for a magazine / dashboard
layout. Works in two modes: (a) col/row-span driven, (b) named-areas
driven via the areas prop.
const BentoGrid: DefineComponent<
ExtractPropTypes<{
items: { type: PropType<BentoGridProps['items']>; required: true }
areas: StringConstructor
columns: { type: NumberConstructor; default: number }
gap: { type: PropType<BentoGridProps['gap']>; default: string }
className: StringConstructor
}>,
() => VNode,
{},
{},
{},
ComponentOptionsMixin,
ComponentOptionsMixin,
{},
string,
PublicProps,
Readonly<
ExtractPropTypes<{
items: { type: PropType<BentoGridProps['items']>; required: true }
areas: StringConstructor
columns: { type: NumberConstructor; default: number }
gap: { type: PropType<BentoGridProps['gap']>; default: string }
className: StringConstructor
}>
> &
Readonly<{}>,
{ gap: 'xs' | 'sm' | 'md' | 'lg' | undefined; columns: number },
{},
{},
{},
string,
ComponentProvideOptions,
true,
{},
any
>
props— Component props (seeBentoGridProps).
Returns: The bento grid component.
CardGrid
Generic responsive card grid. Collapses to one column on narrow viewports
and grows to columns on md+. Typical uses: product grids, post grids,
dashboard widget rows.
const CardGrid: DefineComponent<
ExtractPropTypes<{
children: null
columns: { type: PropType<CardGridProps['columns']>; default: number }
gap: { type: PropType<CardGridProps['gap']>; default: string }
className: StringConstructor
}>,
() => VNode,
{},
{},
{},
ComponentOptionsMixin,
ComponentOptionsMixin,
{},
string,
PublicProps,
Readonly<
ExtractPropTypes<{
children: null
columns: { type: PropType<CardGridProps['columns']>; default: number }
gap: { type: PropType<CardGridProps['gap']>; default: string }
className: StringConstructor
}>
> &
Readonly<{}>,
{ gap: 'xs' | 'sm' | 'md' | 'lg' | undefined; columns: 1 | 2 | 3 | 4 | 5 | 6 | undefined },
{},
{},
{},
string,
ComponentProvideOptions,
true,
{},
any
>
props— Component props (seeCardGridProps).
Returns: The card grid component.
Injection Notes
Requirements
Peer dependencies:
@molecule/app-ui^1.0.1@molecule/app-ui-vue^1.1.0@molecule/app-vue^3.5.0 || ^4.0.0vue^3.4.0
Runtime Dependencies
@molecule/app-ui@molecule/app-ui-vue@molecule/app-vuevue
<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.