Skip to content

GoalCard

Target vs. actual with a progress rule.
Implemented
Status
Implemented
Family
2 of 13
Registry
@lopifi/goal-card
npx shadcn@latest add @lopifi/theme @lopifi/goal-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

Target vs. actual with a progress rule (a rule line, not a rounded progress bar — consistent with the statement grammar).

Lifted verbatim from Cards. 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/goal-card.tsx

Lopifi dependencies · 7
cardcnformat-moneymoneymoney.typespercenttooltip
npm packages
@base-ui-components/reactclass-variance-authorityclsxtailwind-merge
Registry entry
/r/goal-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/goal-card.tsx
import * as React from "react";
import { cn } from "@/lib/ledger/cn";
import type { MoneyValue } from "@/lib/ledger/money.types";
import { Card } from "@/components/ledger/card";
import { Money } from "@/components/ledger/money";
import { Percent } from "@/components/ledger/percent";

export interface GoalCardProps extends React.ComponentPropsWithoutRef<"div"> {
  actual: MoneyValue;
  label: string;
  /** Computed by the caller. */
  progressPercent: number;
  target: MoneyValue;
}

/**
 * The progress indicator is a rule line, not a rounded bar — consistent with
 * the statement grammar rather than borrowed from a generic UI kit.
 */
export const GoalCard = React.forwardRef<HTMLDivElement, GoalCardProps>(
  ({ className, label, actual, target, progressPercent, ...props }, ref) => {
    const clamped = Math.max(0, Math.min(100, progressPercent));
    return (
      <Card className={cn("flex flex-col gap-3", className)} ref={ref} {...props}>
        <span className="text-label font-medium text-text-secondary">{label}</span>
        <div className="flex items-baseline justify-between gap-3">
          <Money size="lg" value={actual} />
          <span className="text-caption text-text-secondary">
            of <Money size="xs" tone="inherit" value={target} />
          </span>
        </div>
        <div
          aria-label={`${label} progress`}
          aria-valuemax={100}
          aria-valuemin={0}
          aria-valuenow={Math.round(clamped)}
          className="relative h-[3px] w-full bg-border-subtle"
          role="progressbar"
        >
          <div className="absolute inset-y-0 left-0 bg-accent" style={{ width: `${clamped}%` }} />
        </div>
        <Percent signed={false} value={{ kind: "relative", value: progressPercent }} />
      </Card>
    );
  },
);
GoalCard.displayName = "GoalCard";

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 Cards

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 GoalCard 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 Cards 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.