@molecule/app-listing-card-solid
Feature · listing-card · App (browser) · v1.2.2 · Apache-2.0
Solid listing/product-card primitives with media, body, actions slots
npm install @molecule/app-listing-card-solidHow it works
@molecule/app-listing-card-solid is a ready-made listing-card feature for the app (browser) side. It composes the core interfaces it needs, so it works with whichever providers your app has bonded.
import {
ListingCard,
ListingCardActions,
ListingCardBody,
ListingCardMedia,
ListingGrid,
} from '@molecule/app-listing-card-solid'
export function Listings(props: { items: Listing[] }) {
return (
<ListingGrid columns={3}>
<ListingCard onClick={() => navigate(`/listings/${props.items[0]!.id}`)}>
<ListingCardMedia src={props.items[0]!.imageUrl} aspect="4/3" alt={props.items[0]!.name} />
<ListingCardBody
title={props.items[0]!.name}
subtitle={props.items[0]!.location}
price={`$${props.items[0]!.price}/night`}
/>
<ListingCardActions>
<button
onClick={(event) => {
event.stopPropagation()
saveListing(props.items[0]!.id)
}}
>
Save
</button>
</ListingCardActions>
</ListingCard>
</ListingGrid>
)
}Works with: @molecule/app-solid, @molecule/app-ui, @molecule/app-ui-solid
Reference
Solid product / property / listing card primitives.
Exports:
<ListingCard>— outer Card shell. Props:children,onClick?,className?,dataMolId?.<ListingCardMedia>— top image slot. Props:src?,alt?,children?(custom media node),aspect?('1/1' | '4/3' | '16/9' | '3/2', default'4/3', applied as an inline aspect-ratio style),overlay?(badge / favorite button, absolutely positioned over the media),className?.<ListingCardBody>— stacked text. Props:title,subtitle?,price?,meta?,className?.<ListingCardActions>— action row. Props:children,layout?('horizontal'default |'stacked'),className?.<ListingGrid>— grid container. Props:children,columns?(1–6, default 3),gap?,className?.
This is the Solid counterpart of @molecule/app-listing-card-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 {
ListingCard,
ListingCardActions,
ListingCardBody,
ListingCardMedia,
ListingGrid,
} from '@molecule/app-listing-card-solid'
export function Listings(props: { items: Listing[] }) {
return (
<ListingGrid columns={3}>
<ListingCard onClick={() => navigate(`/listings/${props.items[0]!.id}`)}>
<ListingCardMedia src={props.items[0]!.imageUrl} aspect="4/3" alt={props.items[0]!.name} />
<ListingCardBody
title={props.items[0]!.name}
subtitle={props.items[0]!.location}
price={`$${props.items[0]!.price}/night`}
/>
<ListingCardActions>
<button
onClick={(event) => {
event.stopPropagation()
saveListing(props.items[0]!.id)
}}
>
Save
</button>
</ListingCardActions>
</ListingCard>
</ListingGrid>
)
}
Type
feature
Installation
npm install @molecule/app-listing-card-solid @molecule/app-solid @molecule/app-ui @molecule/app-ui-solid solid-js
API
Interfaces
ListingCardToggleProps
A server-backed card action with the total number of people who selected it.
interface ListingCardToggleProps extends Omit<OptimisticToggleButtonProps, 'value' | 'commit'> {
/** The pressed state and count from the same loaded record. */
value: { pressed: boolean; count: number }
/** Saves the desired state and returns the server-confirmed state and count together. */
commit: (desired: boolean) => Promise<ListingCardToggleProps['value']>
/** Overrides the button's default `data-mol-id`. */
dataMolId?: string
}
ListingCardProps
Props for ListingCard.
interface ListingCardProps {
/** Slots — usually `<ListingCardMedia>` + `<ListingCardBody>` + `<ListingCardActions>`. */
children: JSX.Element
/** Renders a counted native toggle after the content, outside any links in the content. */
toggle?: ListingCardToggleProps
/**
* Called on any click on the card — including clicks inside
* `<ListingCardActions>`, which bubble into it unless the action handler
* stops propagation. The DOM click event is passed the way React's DOM
* handler receives it.
*/
onClick?: (event: KitMouseEvent) => void
/** Extra classes on the outer Card. */
className?: string
/** `data-mol-id` for AI-agent selectors. */
dataMolId?: string
}
ListingCardActionsProps
Props for ListingCardActions.
interface ListingCardActionsProps {
/** Action content — buttons, favorite toggle, etc. */
children: JSX.Element
/** Layout — `'horizontal'` (default) fills width, `'stacked'` is vertical. */
layout?: 'horizontal' | 'stacked'
/** Extra classes. */
className?: string
}
ListingCardBodyProps
Props for ListingCardBody.
interface ListingCardBodyProps {
/** Primary title / name. */
title: JSX.Element
/** Secondary line (subtitle, location, category). */
subtitle?: JSX.Element
/** Price / metric line. */
price?: JSX.Element
/** Optional extras row (rating, availability, badges). */
meta?: JSX.Element
/** Extra classes. */
className?: string
}
ListingCardMediaProps
Props for ListingCardMedia.
interface ListingCardMediaProps {
/** Image URL. */
src?: string
/** Image alternative text (defaults to an empty string). */
alt?: string
/** Override with a node (video, carousel, svg). */
children?: JSX.Element
/** Aspect ratio (`'1/1' | '4/3' | '16/9' | '3/2'`), applied as an inline `aspect-ratio` style. Defaults to `'4/3'`. */
aspect?: '1/1' | '4/3' | '16/9' | '3/2'
/** Optional overlay node (badge, favorite heart). */
overlay?: JSX.Element
/** Extra classes. */
className?: string
}
ListingGridProps
Props for ListingGrid.
interface ListingGridProps {
/** Grid content — the cards. */
children: JSX.Element
/** Column count, fixed at every viewport width. Defaults to 3. */
columns?: 1 | 2 | 3 | 4 | 5 | 6
/** Gap between cards. Defaults to `'md'`. */
gap?: 'xs' | 'sm' | 'md' | 'lg'
/** Extra classes. */
className?: string
}
Functions
ListingCard(props)
Product / property / listing card shell. Just a <Card> with vertical
stacking of its children — typically <ListingCardMedia> +
<ListingCardBody> + <ListingCardActions>.
This is the Solid counterpart of @molecule/app-listing-card-react's
ListingCard: the same props (React names), the same ClassMap tokens and
the same DOM for the same input.
function ListingCard(props: ListingCardProps): JSX.Element
props— Component props (seeListingCardProps).
Returns: The rendered listing card.
ListingCardActions(props)
Bottom action row of a <ListingCard> (Add to cart, Save, etc.).
This is the Solid counterpart of @molecule/app-listing-card-react's
ListingCardActions: the same props (React names), the same ClassMap
tokens and the same DOM for the same input.
function ListingCardActions(props: ListingCardActionsProps): JSX.Element
props— Component props (seeListingCardActionsProps).
Returns: The rendered action row.
ListingCardBody(props)
Body of a <ListingCard> — title / subtitle / price / meta rows stacked.
Every optional row renders only when its prop carries something, exactly as
React's {node && …} conditions do.
This is the Solid counterpart of @molecule/app-listing-card-react's
ListingCardBody: the same props (React names), the same ClassMap tokens
and the same DOM for the same input.
function ListingCardBody(props: ListingCardBodyProps): JSX.Element
props— Component props (seeListingCardBodyProps).
Returns: The rendered card body.
ListingCardMedia(props)
Media slot at the top of a <ListingCard>. Locks the aspect ratio via an
inline style, renders the caller's node instead of the <img> fallback, and
puts overlay in an absolutely-positioned inset-0 layer.
This is the Solid counterpart of @molecule/app-listing-card-react's
ListingCardMedia: the same props (React names), the same ClassMap tokens,
inline styles and DOM for the same input.
function ListingCardMedia(props: ListingCardMediaProps): JSX.Element
props— Component props (seeListingCardMediaProps).
Returns: The rendered media slot.
ListingGrid(props)
Grid for <ListingCard>s — a fixed columns-column grid at every viewport
width.
This is the Solid counterpart of @molecule/app-listing-card-react's
ListingGrid: the same props (React names), the same ClassMap tokens and
the same DOM for the same input.
function ListingGrid(props: ListingGridProps): JSX.Element
props— Component props (seeListingGridProps).
Returns: The rendered grid.
Injection Notes
Requirements
Peer dependencies:
@molecule/app-solid^3.14.0 || ^4.0.0@molecule/app-ui^1.5.0@molecule/app-ui-solid^1.1.0solid-js^1.8.0
Runtime Dependencies
-
@molecule/app-solid -
@molecule/app-ui -
@molecule/app-ui-solid -
solid-js -
ListingCard.onClickis attached to the WHOLE card — clicks on buttons inside<ListingCardActions>bubble into it. Callevent.stopPropagation()in every action handler (as in the example) or the card navigation fires too. -
<ListingGrid columns={n}>renders a fixed n-column grid (viacm.grid); overrideclassNamefor a custom grid. -
overlaychildren are rendered inside an absolutely-positioned inset-0 layer; give interactive overlays their own pointer handling and stopPropagation. -
Styling resolves through
getClassMap(); the shell uses<Card>from@molecule/app-ui-solid— wire a ClassMap bond first.