@molecule/app-related-items-card-solid
Feature · related-items-card · App (browser) · v1.1.2 · Apache-2.0
Card container for cross-linked items: company→deals, contact→notes, ticket→articles
npm install @molecule/app-related-items-card-solidHow it works
@molecule/app-related-items-card-solid is a ready-made related-items-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 { For } from 'solid-js'
import { RelatedItemsCard } from '@molecule/app-related-items-card-solid'
interface Article {
id: string
title: string
}
export function RelatedArticles(props: { articles: Article[]; onOpen: (id: string) => void }) {
return (
<RelatedItemsCard
title="Related Articles"
items={props.articles}
viewAllHref="/articles"
emptyState={<p>No related articles yet.</p>}
renderItem={(article) => <span>{article.title}</span>}
onItemClick={(article) => props.onOpen(article.id)}
/>
)
}Works with: @molecule/app-solid, @molecule/app-ui, @molecule/app-ui-solid
Reference
Solid card container for cross-linked / related item lists.
Exports RelatedItemsCard — the Solid counterpart of
@molecule/app-related-items-card-react: a titled Card with header + list +
empty state + "View all" link, with the same props (React names) and the
same DOM for the same input. Use for "Company → Deals", "Contact → Notes",
"Ticket → Related Articles" panels.
Props: title (JSX), items: T[], renderItem(item, index), icon?,
onItemClick?(item, index) (rows become clickable), emptyState? (rendered
when items is empty), viewAllHref? (header "View all" link),
headerActions? (right-aligned header slot), className?, dataMolId?.
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 { For } from 'solid-js'
import { RelatedItemsCard } from '@molecule/app-related-items-card-solid'
interface Article {
id: string
title: string
}
export function RelatedArticles(props: { articles: Article[]; onOpen: (id: string) => void }) {
return (
<RelatedItemsCard
title="Related Articles"
items={props.articles}
viewAllHref="/articles"
emptyState={<p>No related articles yet.</p>}
renderItem={(article) => <span>{article.title}</span>}
onItemClick={(article) => props.onOpen(article.id)}
/>
)
}
Type
feature
Installation
npm install @molecule/app-related-items-card-solid @molecule/app-solid @molecule/app-ui @molecule/app-ui-solid solid-js
API
Interfaces
RelatedItemsCardProps
Props accepted by the RelatedItemsCard component.
interface RelatedItemsCardProps<T> {
/** Card heading. */
title: JSX.Element
/** Optional leading icon in the header. */
icon?: JSX.Element
/** Items to render. */
items: readonly T[]
/** Render function for each item. */
renderItem: (item: T, index: number) => JSX.Element
/** Called when an item row is clicked (if applicable). */
onItemClick?: (item: T, index: number) => void
/** Rendered when `items` is empty. */
emptyState?: JSX.Element
/** Optional "View all" link rendered in the header. */
viewAllHref?: string
/** Optional right-aligned header actions (e.g. "Add new" button). */
headerActions?: JSX.Element
/** Extra classes on the Card. */
className?: string
/** `data-mol-id` for AI-agent selectors. */
dataMolId?: string
}
Functions
RelatedItemsCard(props)
Card container for a list of cross-linked / related items.
Common usage: "Company → Deals", "Contact → Notes", "Ticket → Related Articles", "Post → Related Posts". Apps supply the item data and a renderer; the card provides consistent header + list + empty-state + view-all chrome.
Clickable rows (onItemClick): the <li> stays a list item and the card
wraps the row content in an inner role="button" div — focusable, with
Enter/Space running the same handler the click does.
Rows keep their DOM node while the item at their index changes, as React's
index-keyed rows do: <Index> reconciles by position and the memo rebuilds
the rendered content for the new item.
function RelatedItemsCard<T>(props: RelatedItemsCardProps<T>): JSX.Element
props— Component props (seeRelatedItemsCardProps).
Returns: The rendered related items card.
Injection Notes
Requirements
Peer dependencies:
@molecule/app-solid^3.5.0 || ^4.0.0@molecule/app-ui^1.0.1@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 -
Requires a bonded ClassMap — call
setClassMap()(e.g. with@molecule/app-ui-tailwind) at startup or rendering throws. -
The "View all" label is hardcoded English in the React reference (not routed through i18n) and is the same literal here; pass a translated link via
headerActionsin localized apps. -
onItemClickrows stay<li>list items: the card wraps each row's content in an innerrole="button"control (focusable, Enter/Space activate it) so the click works from the keyboard too. A real<button>/<a>insiderenderItemstill takes its own clicks and focus. -
viewAllHrefrenders a plain<a href>(full page load in SPA routers); useheaderActionswith your router's Link for client-side navigation.