Skip to content

TransactionCard

The mobile re-rank.
Implemented
Status
Implemented
Family
5 of 13
Registry
@lopifi/transaction-card
npx shadcn@latest add @lopifi/theme @lopifi/transaction-card

The component, rendering

Real data, the shipped component. Switch the theme to check the claims the spec makes below.

Preview

The four-layer spec

The mobile re-rank. 72px, 16px inset, full-bleed divider, amount right-aligned and never truncated, 32px mark, swipe-left actions with an overflow-menu equivalent because swipe is undiscoverable. Sticky date section headers.

Lifted verbatim from Ledger & tables. The doc and this page are the same paragraphs, so they cannot disagree.

What lands in your repository

One component is never one file. Everything below is copied into your project, where you own it.

Files

components/ledger/transaction-card.tsx

Lopifi dependencies · 21
clipboardcncolumn-headerentity-markfiscal-periodformat-moneygroup-rowsiconsmoneymoney.typesreferencestatus-pilltable-sorttooltiptransaction-cardtransaction-tableuse-column-priorityuse-column-widthsuse-densityuse-grid-navuse-table-sort
npm packages
@base-ui-components/react@tanstack/react-virtualclass-variance-authorityclsxtailwind-merge
Registry entry
/r/transaction-card.json

The whole component

No compiled bundle, no black box. This is the file the registry copies, and the file you will edit.

components/ledger/transaction-card.tsx
"use client";

import { Checkbox } from "@base-ui-components/react/checkbox";
import { cn } from "@/lib/ledger/cn";
import { formatDateShort } from "@/lib/ledger/fiscal-period";
import { EntityMark } from "@/components/ledger/entity-mark";
import { CheckIcon, EllipsisHorizontalIcon } from "@/components/ledger/icons";
import { Money } from "@/components/ledger/money";
import { StatusPill } from "@/components/ledger/status-pill";
import type { Transaction } from "@/components/ledger/transaction-table";

export interface TransactionCardProps {
  onOpen?: () => void;
  onToggle?: () => void;
  selected?: boolean;
  transaction: Transaction;
}

/**
 * The mobile re-rank, not a squeezed table row: 72px, 16px inset, full-bleed
 * divider, 32px mark, amount right-aligned and never truncated.
 *
 * Swipe is undiscoverable, so the overflow menu is the equivalent and it is
 * always present.
 */
export function TransactionCard({
  transaction: t,
  selected = false,
  onToggle,
  onOpen,
}: TransactionCardProps) {
  return (
    <li
      className={cn(
        "flex min-h-[72px] items-center gap-3 border-b border-border-subtle px-4 last:border-b-0",
        selected && "bg-surface-selected",
        // Pending is the warning rule and the "Pending" label, never a dimmed
        // row: at 70% its secondary text fell to 3.2:1.
        t.pending && "border-l-2 border-l-[var(--warning)]",
      )}
    >
      {onToggle ? (
        <Checkbox.Root
          aria-label={`Select ${t.description}`}
          checked={selected}
          className="grid size-5 shrink-0 place-items-center rounded-xs border border-border-strong bg-surface data-[checked]:border-accent data-[checked]:bg-accent"
          onCheckedChange={onToggle}
        >
          <Checkbox.Indicator className="text-accent-fg">
            <CheckIcon className="size-3.5" />
          </Checkbox.Indicator>
        </Checkbox.Root>
      ) : null}

      <EntityMark name={t.merchant ?? t.description} size={32} />

      <button className="min-w-0 flex-1 py-3 text-left" onClick={onOpen} type="button">
        <span className="block truncate text-body font-medium">{t.description}</span>
        <span className="mt-0.5 block truncate text-caption text-text-secondary">
          <span className="numeric">{formatDateShort(t.date)}</span> · {t.account}{" "}
          <span className="reference-numeric">••{t.accountLast4}</span>
        </span>
        {t.status !== "settled" ? (
          <span className="mt-1 inline-block">
            <StatusPill entity="Transaction" status={t.status} />
          </span>
        ) : null}
      </button>

      <div className="flex shrink-0 flex-col items-end gap-1">
        <Money accounting colorBySign value={t.amount} />
        <button
          aria-label={`Actions for ${t.description}`}
          className="press grid size-8 place-items-center rounded-sm text-text-tertiary hover:bg-surface-hover"
          type="button"
        >
          <EllipsisHorizontalIcon aria-hidden="true" className="size-4" />
        </button>
      </div>
    </li>
  );
}

The accounting it encodes

Concepts this component renders. Each one is defined once, in the lexicon, and used identically in the code and the copy.

Also in Ledger & tables

See also

A component is specified in one place, defined in another, and running in a third. All three, from here.

Elsewhere in the system

Where TransactionCard sits in the rest of the system — the live section it renders in, the calculators that compute what it displays, and the ledger payloads it is fed from.

Components are copied into your repository and meant to be edited — rounding policy, fiscal calendar and compliance copy differ per company.

Told when Ledger & tables changes

Components are copied into your repo, so a fix here does not reach you on its own. One email when a component in this family changes in a way that needs a migration — and nothing when it does not.

One address, no list rental, unsubscribe in one click.

Works in your QuickBooks Online or Xero file

Get your books closed every month

Lopifi is building AI bookkeeping that keeps your books closed on US GAAP as transactions happen, with a CPA review every quarter, for $200 a month. We’re not open yet.

$200/month when we open. No card now.