@molecule/app-list-item-row-react

Feature · list-item-row · App (browser) · v4.2.1 · Apache-2.0

Thumbnail + title + subtitle + metadata + actions row (nav lists, mobile menus)

npm install @molecule/app-list-item-row-react

npm · Source on GitHub

How it works

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

import { ListItemRow } from '@molecule/app-list-item-row-react'

;<ListItemRow
  title="Project Alpha"
  subtitle="Last edited 2 hours ago"
  metadata="3 collaborators · 12 files"
  leading={<img src="/icons/folder.svg" alt="" width={32} height={32} />}
  toggle={{
    value: project.pinned,
    commit: async (desired) => (await setPinned(project.id, desired)).pinned,
    activeLabel: t('projects.unpin', undefined, { defaultValue: 'Unpin project' }),
    inactiveLabel: t('projects.pin', undefined, { defaultValue: 'Pin project' }),
  }}
  onClick={() => navigate('/projects/alpha')}
/>

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

Reference

Generic list-item row.

Exports <ListItemRow> — leading slot (icon/avatar/thumbnail) + up to three text lines (title / subtitle / metadata) + right-side actions. Props: title, subtitle?, metadata?, leading?, actions?, toggle?, onClick?, selected?, disabled?, density? ('comfortable' default | 'compact'), className?. Use for nav lists, mobile menus, search results, picker dialogs, inbox threads. For table rows use <RowWithActions> from @molecule/app-data-table-ui-react instead — this component is not a <tr>.

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

import { ListItemRow } from '@molecule/app-list-item-row-react'

;<ListItemRow
  title="Project Alpha"
  subtitle="Last edited 2 hours ago"
  metadata="3 collaborators · 12 files"
  leading={<img src="/icons/folder.svg" alt="" width={32} height={32} />}
  toggle={{
    value: project.pinned,
    commit: async (desired) => (await setPinned(project.id, desired)).pinned,
    activeLabel: t('projects.unpin', undefined, { defaultValue: 'Unpin project' }),
    inactiveLabel: t('projects.pin', undefined, { defaultValue: 'Pin project' }),
  }}
  onClick={() => navigate('/projects/alpha')}
/>

Type

feature

Installation

npm install @molecule/app-list-item-row-react @molecule/app-react @molecule/app-ui @molecule/app-ui-react react
npm install -D @types/react

API

Interfaces

ListItemRowProps

Props for ListItemRow.

interface ListItemRowProps {
  /** Title — first line. */
  title: ReactNode
  /** Optional second line (excerpt, description). */
  subtitle?: ReactNode
  /** Optional third line (metadata — timestamps, counts, tags). */
  metadata?: ReactNode
  /** Optional leading slot — icon, avatar, thumbnail image. */
  leading?: ReactNode
  /** Optional right-side actions (buttons, action menu). */
  actions?: ReactNode
  /** Loaded boolean action rendered as a native button, independently of read-only metadata. */
  toggle?: OptimisticToggleButtonProps
  /**
   * Called when the row is activated. The whole row is clickable through a
   * transparent native button over it, named by the title; the inner controls
   * (the `actions` slot) sit above it and keep their own clicks.
   */
  onClick?: () => void
  /** When true, sets `aria-current="true"` on the row — no built-in visual highlight; style it via `className` or host CSS. */
  selected?: boolean
  /** When true, renders in a disabled visual state and disables the open button. */
  disabled?: boolean
  /** Dense vs comfortable spacing. Defaults to `'comfortable'`. */
  density?: 'comfortable' | 'compact'
  /** Extra classes. */
  className?: string
}

Functions

ListItemRow(props)

Generic "thumbnail + text + actions" row — used everywhere: navigation lists, mobile menus, inbox-style threads, search results, picker dialogs, bookmark lists, etc.

With onClick the whole row is clickable through a transparent native <button type="button"> stretched over it — named by the title (aria-labelledby) — so mouse and keyboard users get the same action and the hit area is the whole row, not just the text. The actions slot sits above that button (a position: relative wrapper), so its clicks stay its own; everything else sits under it, so a click anywhere else on the row runs the handler. disabled disables the button and drops the pointer cursor. Unstyled apart from the transparent button, so the row looks as it did.

Different from <RowWithActions> in @molecule/app-data-table-ui-react in NOT being a <tr> — use this for non-table lists.

function ListItemRow({
  title,
  subtitle,
  metadata,
  leading: leadingProp,
  actions: actionsProp,
  toggle,
  onClick,
  selected,
  disabled,
  density = 'comfortable',
  className,
}: ListItemRowProps): JSX.Element
  • props — Component props (see ListItemRowProps).

Injection Notes

Requirements

Peer dependencies:

  • @molecule/app-react ^4.13.0 || ^5.0.0
  • @molecule/app-ui ^1.0.1
  • @molecule/app-ui-react ^4.4.0
  • react ^18.0.0 || ^19.0.0

Runtime Dependencies

  • @molecule/app-react

  • @molecule/app-ui

  • @molecule/app-ui-react

  • react

  • selected only sets the aria-current="true" attribute — no built-in highlight. Pass a highlight class via className (or target [aria-current="true"] in host CSS) to make selection visible.

  • With onClick the whole row is clickable through a transparent native button over it, named by the title (aria-labelledby); Enter / Space on that button run the same handler a click anywhere on the row runs, and the inner controls (the actions slot) sit above the button and keep their own clicks.

  • disabled halves the opacity and disables the open button (no pointer cursor, no activation); there is no data-mol-id prop.

  • Pass toggle for a loaded server-backed action that belongs on the row. It renders the real OptimisticToggleButton beside any read-only counts in metadata. Key each row by record identity when rendering a collection.

  • Styling resolves through getClassMap() — wire a ClassMap bond first.