Skip to content

RunwayCard

Months of runway with a burn line.
Implemented
Status
Implemented
Family
2 of 13
Registry
@lopifi/runway-card
terminal
npx shadcn@latest add @lopifi/theme @lopifi/runway-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

Months of runway, current cash, monthly burn, projected zero date. A burn line with a projection segment rendered dashed, because a projection is not a fact.

polarity="inverted" on burn. Runway under 6 months triggers --warning; under 3, --negative — and the threshold is configurable, because it's a business judgment, not a universal truth.

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/runway-card.tsx

Lopifi dependencies · 10
cardcnfiscal-periodformat-moneyiconsmoneymoney.typesprimitive-tooltipstatus-pilltooltip
npm packages
@base-ui-components/reactclass-variance-authorityclsxtailwind-merge
Registry entry
/r/runway-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/runway-card.tsx
"use client";

import * as React from "react";
import { cn } from "@/lib/ledger/cn";
import { formatDate } from "@/lib/ledger/fiscal-period";
import type { MoneyValue } from "@/lib/ledger/money.types";
import { Card } from "@/components/ledger/card";
import { Money } from "@/components/ledger/money";
import { StatusPill } from "@/components/ledger/status-pill";

export interface RunwayCardProps extends React.ComponentPropsWithoutRef<"div"> {
  /** Actual burn history, then the projection. */
  actual: number[];
  cash: MoneyValue;
  criticalMonths?: number;
  monthlyBurn: MoneyValue;
  months: number;
  projected: number[];
  /** A business judgment, not a universal truth. */
  warningMonths?: number;
  zeroDate: Date;
}

/**
 * Burn is `polarity="inverted"` — an increase is not good news.
 * The projection segment is dashed, because a projection is not a fact.
 */
export const RunwayCard = React.forwardRef<HTMLDivElement, RunwayCardProps>(
  (
    {
      className,
      months,
      cash,
      monthlyBurn,
      zeroDate,
      actual,
      projected,
      warningMonths = 6,
      criticalMonths = 3,
      ...props
    },
    ref,
  ) => {
    const severity = months < criticalMonths ? "critical" : months < warningMonths ? "warning" : "ok";

    return (
      <Card className={cn("flex flex-col", className)} ref={ref} {...props}>
        <div className="flex items-start justify-between gap-4">
          <span className="text-label font-medium text-text-secondary">Runway</span>
          {severity !== "ok" ? (
            <StatusPill entity="Runway" status={severity === "critical" ? "overdue" : "needs-review"} />
          ) : null}
        </div>

        <p
          className={cn(
            "numeric mt-2 text-figure-hero font-medium leading-none",
            severity === "critical" && "text-negative",
            severity === "warning" && "text-warning",
          )}
        >
          {months.toFixed(1)}
          <span className="ml-2 text-title-md font-normal text-text-secondary">months</span>
        </p>

        <p className="mt-2 text-caption text-text-secondary">
          Cash <Money size="xs" tone="inherit" value={cash} /> · burn{" "}
          <Money size="xs" tone="inherit" value={monthlyBurn} />
          /mo · zero {formatDate(zeroDate)}
        </p>

        <BurnLine actual={actual} className="mt-4" projected={projected} />
      </Card>
    );
  },
);
RunwayCard.displayName = "RunwayCard";

function BurnLine({
  actual,
  projected,
  className,
}: {
  actual: number[];
  projected: number[];
  className?: string;
}) {
  const all = [...actual, ...projected];
  const max = Math.max(...all, 1);
  const width = 240;
  const height = 56;
  const step = width / (all.length - 1);
  const point = (v: number, i: number) =>
    `${(i * step).toFixed(1)},${(height - (v / max) * height).toFixed(1)}`;

  const actualPath = actual.map((v, i) => `${i === 0 ? "M" : "L"}${point(v, i)}`).join(" ");
  const projectedPath = projected
    .map((v, i) => `${i === 0 ? "M" : "L"}${point(v, actual.length - 1 + i)}`)
    .join(" ");
  const bridge = `M${point(actual[actual.length - 1], actual.length - 1)} L${point(projected[0], actual.length - 1)}`;

  return (
    <svg
      aria-label="Cash balance, actual then projected to zero"
      className={cn("h-14 w-full", className)}
      preserveAspectRatio="none"
      role="img"
      viewBox={`0 0 ${width} ${height}`}
    >
      <line
        stroke="var(--border-strong)"
        strokeWidth="1"
        vectorEffect="non-scaling-stroke"
        x1="0"
        x2={width}
        y1={height}
        y2={height}
      />
      <path
        d={actualPath}
        fill="none"
        stroke="var(--viz-1)"
        strokeWidth="1.5"
        vectorEffect="non-scaling-stroke"
      />
      <path
        d={bridge}
        fill="none"
        stroke="var(--viz-1)"
        strokeDasharray="4 3"
        strokeWidth="1.5"
        vectorEffect="non-scaling-stroke"
      />
      <path
        d={projectedPath}
        fill="none"
        opacity="0.8"
        stroke="var(--viz-1)"
        strokeDasharray="4 3"
        strokeWidth="1.5"
        vectorEffect="non-scaling-stroke"
      />
    </svg>
  );
}

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 RunwayCard 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.

Get an email 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 needs a migration, and nothing when it does not.

One address, no list rental. Ask to be taken off and you are.

We use this to reply and to send the updates you asked for. See Privacy.