@molecule/app-transactions-table-react

Feature · transactions-table · App (browser) · v4.1.1 · Apache-2.0

Finance ledger table with loading/error/empty states

npm install @molecule/app-transactions-table-react

npm · Source on GitHub

How it works

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

import {
  TransactionsTable,
  type CategoryStyle,
  type TransactionRowData,
} from '@molecule/app-transactions-table-react'

// Category colours are the caller's data (a category palette it picked):
// the prop takes raw CSS colours by design; the component's own chrome is
// ClassMap-styled.
const categoryStyles: Record<string, CategoryStyle> = {
  groceries: { bg: '#d1fae5', color: '#059669', icon: 'shopping_cart' },
  rent: { bg: '#ffe4e6', color: '#e11d48', icon: 'home' },
}

const rows: TransactionRowData[] = [
  {
    id: 't1',
    date: '2026-03-01',
    description: 'Groceries',
    categoryKey: 'groceries',
    categoryLabel: 'Groceries',
    account: 'Checking',
    amount: -54.2,
  },
]

<TransactionsTable
  transactions={rows}
  categoryStyles={categoryStyles}
  onRowClick={(tx) => console.log('open', tx.id)}
/>

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

Reference

@molecule/app-transactions-table-react — financial transactions table primitive.

  • Columns: Date / Description (with category icon tile) / Category chip / Account / signed Amount (income tinted with the theme's primary token, expense with tertiary).
  • Loading skeleton, error state with retry, customisable empty state.
  • Stateless about routing: pass onRowClick to navigate.
  • Localisable: column headers and the retry label go through t() (transactionsTable.header.*, transactionsTable.label.retry); the default formatters format in the app's active locale, the amount in the currency prop. formatAmount, formatDate, headers, retryLabel and emptyState still override the defaults.

Generalised from the personal-finance TransactionsTable. Works for any income/expense ledger: subscription billing rows, refund tables, payout history, etc.

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 {
  TransactionsTable,
  type CategoryStyle,
  type TransactionRowData,
} from '@molecule/app-transactions-table-react'

// Category colours are the caller's data (a category palette it picked):
// the prop takes raw CSS colours by design; the component's own chrome is
// ClassMap-styled.
const categoryStyles: Record<string, CategoryStyle> = {
  groceries: { bg: '#d1fae5', color: '#059669', icon: 'shopping_cart' },
  rent: { bg: '#ffe4e6', color: '#e11d48', icon: 'home' },
}

const rows: TransactionRowData[] = [
  {
    id: 't1',
    date: '2026-03-01',
    description: 'Groceries',
    categoryKey: 'groceries',
    categoryLabel: 'Groceries',
    account: 'Checking',
    amount: -54.2,
  },
]

<TransactionsTable
  transactions={rows}
  categoryStyles={categoryStyles}
  onRowClick={(tx) => console.log('open', tx.id)}
/>

Type

feature

Installation

npm install @molecule/app-transactions-table-react @molecule/app-react @molecule/app-ui @molecule/app-ui-react react
npm install -D @types/react

API

Interfaces

TransactionsTableProps

Props for the TransactionsTable component.

interface TransactionsTableProps {
  transactions: TransactionRowData[]
  loading?: boolean
  error?: ReactNode
  onRetry?: () => void
  /**
   * Label of the retry button. Overrides the translated default
   * (`transactionsTable.label.retry`, English `'Try again'`).
   */
  retryLabel?: ReactNode
  /**
   * Map a category key (lowercased automatically) to a style; a key without an
   * entry falls back to the theme's neutral chip (`cm.surfaceSecondary` +
   * `cm.textMuted`, the `receipt` icon).
   */
  categoryStyles?: Record<string, CategoryStyle>
  /**
   * ISO 4217 code the default amount formatter formats in (`'USD'` when
   * omitted); a `formatAmount` prop wins over it.
   */
  currency?: string
  /**
   * Localised currency formatter; defaults to the app's active locale
   * (`useLocale()`) and the `currency` prop, so a locale switch re-formats at
   * once. An explicit formatter still wins.
   */
  formatAmount?: (amount: number) => string
  /**
   * Localised date formatter ("MMM d, yyyy"); defaults to the app's active
   * locale (`useLocale()`), so a locale switch re-formats at once. An explicit
   * formatter still wins.
   */
  formatDate?: (date: string | Date) => string
  /** Click handler for each row (typically navigates to a detail page). */
  onRowClick?: (row: TransactionRowData) => void
  /**
   * Column header labels (pre-translated). Each overrides the translated
   * default (`transactionsTable.header.*`).
   */
  headers?: {
    date?: ReactNode
    description?: ReactNode
    category?: ReactNode
    account?: ReactNode
    amount?: ReactNode
  }
  /** Empty-state slot (rendered when transactions.length === 0). */
  emptyState?: ReactNode
  /** Optional footer slot (typically a pagination control). */
  footer?: ReactNode
  className?: string
}

TransactionRowData

Per-row data. Stays minimal so the consumer can fold their domain shape in.

interface TransactionRowData {
  id: string
  date: string | Date
  description: ReactNode
  /** Category key (used for the icon + chip styling lookup). */
  categoryKey: string
  categoryLabel: ReactNode
  /** Account name / id rendered in the Account column. */
  account: ReactNode
  /** Signed amount (positive = income, negative = expense) — used for the colour + sign. */
  amount: number
  /** Override sign detection (e.g. when `type` is the canonical signal). */
  isIncome?: boolean
}

CategoryStyle

Visual treatment for a particular category key.

interface CategoryStyle {
  bg: string
  color: string
  icon: string
}

Functions

TransactionsTable(props)

Renders a pageable financial transactions table with loading, error, and empty states.

function TransactionsTable({
  transactions,
  loading,
  error,
  onRetry,
  retryLabel,
  categoryStyles,
  currency = 'USD',
  formatAmount,
  formatDate,
  onRowClick,
  headers,
  emptyState,
  footer,
  className,
}: TransactionsTableProps): JSX.Element

Injection Notes

Requirements

Peer dependencies:

  • @molecule/app-react ^4.0.0 || ^5.0.0
  • @molecule/app-ui ^1.3.11
  • @molecule/app-ui-react ^4.7.0
  • react ^18.0.0 || ^19.0.0

Runtime Dependencies

  • @molecule/app-react
  • @molecule/app-ui
  • @molecule/app-ui-react
  • react

A custom formatAmount receives the SIGNED amount but must return the absolute formatted value — the component prepends its own +/− sign (the default already does Math.abs). Header labels and the retry label default to English through t() (transactionsTable.header.*, transactionsTable.label.retry; companion locale bond @molecule/app-locales-transactions-table), and the date/amount defaults format in the app's active locale (useLocale()), the amount in the currency prop (default 'USD'). Pass headers / retryLabel / formatAmount / formatDate to override any of them. categoryStyles keys are matched against the LOWERCASED categoryKey; icon is a Material Symbols ligature name (rendered aria-hidden, since the chip names the category), so the host must load that font. Styling mixes ClassMap with raw Tailwind + Material-3 tokens (bg-surface-container-lowest, font-headline, text-slate-400/500), so a Tailwind build source-scanning this package's dist + an M3 theme are prerequisites, and the slate grays lean light-theme. Props (documented on the exported TransactionsTableProps interface): transactions, loading, error, onRetry, retryLabel, categoryStyles, currency, formatAmount, formatDate, onRowClick, headers, emptyState, footer, className.

Translations

Translation strings are provided by @molecule/app-locales-transactions-table.