Skip to content
Organisms

Invoice

Line items, tax, total and a pay button.

Primitive

Installation

Primitive
  1. Run the CLI

    Run pnpm dlx asta-ui@latest init once, then this. The file lands in components/astabyte/, installs radix-ui@base-ui/react and the colour tokens go into your CSS. This is the Radix build. Drop --radix for Base UI.This is the Base UI build, the default. Want Radix? Add --radix.

    $ pnpm dlx asta-ui@latest add invoice --radix

    Or with the shadcn CLI: pnpm dlx shadcn@latest add https://ui.astabyte.com/r/base/invoice.json

  2. Or install the package

    Don’t want the file? Import from asta-uiasta-ui/base and update with pnpm update asta-ui. Add the stylesheet once. More.

    $ pnpm add asta-ui radix-ui @base-ui/react
    import { Invoice } from "asta-ui";
    import { Invoice } from "asta-ui/base";
  3. Or copy it by hand

    Install radix-ui@base-ui/react, then copy these files. Keep the paths, or fix the @/ imports. Then add the tokens from globals.css.

    "use client";
    
    import { useEffect, useMemo, useRef, useState, type ReactNode } from "react";
    import { Button } from "@/components/kit/button";
    
    const cx = (...c: (string | false | null | undefined)[]) => c.filter(Boolean).join(" ");
    
    const KEYFRAMES = `@keyframes asta-invoice-in { from { opacity: 0; transform: translateY(4px) } }
    @keyframes asta-invoice-draw { from { stroke-dashoffset: 1 } }
    @keyframes asta-invoice-pop { 0% { transform: scale(.6); opacity: 0 } 60% { transform: scale(1.08) } 100% { transform: none; opacity: 1 } }
    @media (prefers-reduced-motion: reduce) { .asta-invoice-a { animation: none !important } }`;
    
    export type InvoiceStatus = "draft" | "due" | "overdue" | "paid";
    
    export interface InvoiceLine {
      description: string;
      /** A muted second line, e.g. the period it covers. */
      detail?: string;
      quantity: number;
      unitPrice: number;
    }
    
    export interface InvoiceParty {
      name: string;
      /** Address, email, tax id: one per line. */
      lines: string[];
    }
    
    export interface InvoiceProps {
      number: string;
      /** Already formatted dates, e.g. "Nov 1, 2026". */
      issued: string;
      due: string;
      from: InvoiceParty;
      to: InvoiceParty;
      items: InvoiceLine[];
      /** e.g. 0.11 for 11%. */
      taxRate?: number;
      /** An amount taken off before tax. */
      discount?: number;
      currency?: string;
      locale?: string;
      status?: InvoiceStatus;
      notes?: ReactNode;
      /** Logo or wordmark at the top left. */
      brand?: ReactNode;
      /** Shows Pay. Resolve to mark it paid, throw to stay due. */
      onPay?: () => Promise<void> | void;
      /** Shows Download. */
      onDownload?: () => void;
      className?: string;
    }
    
    const STATUS: Record<InvoiceStatus, { label: string; cls: string }> = {
      draft: { label: "Draft", cls: "text-mute shadow-[inset_0_0_0_1px_color-mix(in_srgb,var(--color-ink)_16%,transparent)]" },
      due: { label: "Due", cls: "bg-paper-2 text-ink" },
      overdue: { label: "Overdue", cls: "bg-ink text-paper" },
      paid: { label: "Paid", cls: "bg-[color-mix(in_srgb,var(--color-brand)_12%,transparent)] text-brand" },
    };
    
    /**
     * An invoice: who it's from and to, line items, tax and the total. Pay shows a pending state, then the status
     * turns to Paid, the amount due drops to zero and a check draws itself in. Wrap it in nothing: it sets its own
     * container, so line items stack when the card is narrow, not the window.
     */
    export function Invoice({ number, issued, due, from, to, items, taxRate = 0, discount = 0, currency = "USD", locale = "en-US", status = "due", notes, brand, onPay, onDownload, className }: InvoiceProps) {
      const [state, setState] = useState<InvoiceStatus>(status);
      const [paying, setPaying] = useState(false);
      const [paidOn, setPaidOn] = useState<string | null>(null);
      const [error, setError] = useState<string | null>(null);
      const errorEl = useRef<HTMLParagraphElement>(null);
      // A failed payment moves focus to the message, so keyboard and screen reader users hear it.
      useEffect(() => {
        if (error) errorEl.current?.focus();
      }, [error]);
      // One formatter per locale and currency. Building one per call cost ~70ms on a throttled phone.
      const money = useMemo(() => {
        const f = new Intl.NumberFormat(locale, { style: "currency", currency });
        return (n: number) => f.format(n);
      }, [locale, currency]);
    
      const subtotal = items.reduce((a, it) => a + it.quantity * it.unitPrice, 0);
      const taxed = Math.max(0, subtotal - discount);
      const tax = Math.round(taxed * taxRate * 100) / 100;
      const total = taxed + tax;
      const paid = state === "paid";
      const s = STATUS[state];
    
      const pay = async () => {
        if (!onPay || paying) return;
        setPaying(true);
        setError(null);
        try {
          await onPay();
          setPaidOn(new Date().toLocaleDateString(locale, { month: "short", day: "numeric", year: "numeric" }));
          setState("paid");
        } catch (e) {
          const why = e instanceof Error && e.message ? ` ${e.message.replace(/\.?$/, ".")}` : "";
          setError(`The payment didn't go through.${why} Check your payment details and try again.`);
        } finally {
          setPaying(false);
        }
      };
    
      return (
        <article
          aria-label={`Invoice ${number}`}
          className={cx("@container w-full rounded-[14px] bg-paper text-ink shadow-[inset_0_0_0_1px_color-mix(in_srgb,var(--color-ink)_10%,transparent),0_18px_44px_-28px_rgb(0_0_0/0.3)]", className)}
        >
          <style href="asta-invoice" precedence="asta">{KEYFRAMES}</style>
          <div className="flex flex-col gap-7 p-5 @min-[560px]:p-8">
            {/* Head */}
            <header className="flex flex-wrap items-start justify-between gap-4">
              <div className="min-w-0">{brand ?? <p className="text-[17px] font-semibold tracking-[-0.03em]">{from.name}</p>}</div>
              <div className="flex flex-col items-end gap-1.5 text-right">
                <div className="flex items-center gap-2">
                  <h2 className="text-[20px] font-medium tracking-[-0.03em]">Invoice</h2>
                  <span key={state} className={cx("asta-invoice-a inline-flex h-6 animate-[asta-invoice-pop_.45s_cubic-bezier(.16,1,.3,1)_both] items-center gap-1 rounded-md px-2 text-[11.5px] font-medium", s.cls)}>
                    {paid ? (
                      <svg viewBox="0 0 24 24" className="h-3 w-3" fill="none" stroke="currentColor" strokeWidth="3.3" strokeLinecap="round" strokeLinejoin="round" aria-hidden>
                        <path d="m5 12.5 4.5 4.5L19 7.5" pathLength={1} strokeDasharray={1} className="asta-invoice-a animate-[asta-invoice-draw_.5s_cubic-bezier(.16,1,.3,1)_.15s_both]" />
                      </svg>
                    ) : state === "overdue" ? (
                      <svg viewBox="0 0 24 24" className="h-3 w-3" fill="none" stroke="currentColor" strokeWidth="2.7" strokeLinecap="round" aria-hidden>
                        <path d="M12 7.5v5" />
                        <path d="M12 16h.01" />
                      </svg>
                    ) : null}
                    {s.label}
                  </span>
                </div>
                <p className="font-mono text-[12px] text-mute">{number}</p>
              </div>
            </header>
    
            {/* Parties and dates */}
            <div className="grid gap-5 text-[13px] @min-[560px]:grid-cols-[1fr_1fr_auto] @min-[560px]:gap-8">
              {[
                ["Billed to", to],
                ["From", from],
              ].map(([title, p]) => {
                const party = p as InvoiceParty;
                return (
                  <div key={title as string} className="min-w-0">
                    <p className="font-mono text-[10.5px] uppercase tracking-wider text-mute">{title as string}</p>
                    <p className="mt-1.5 font-medium">{party.name}</p>
                    {party.lines.map((l) => (
                      <p key={l} className="text-mute">
                        {l}
                      </p>
                    ))}
                  </div>
                );
              })}
              <dl className="grid grid-cols-2 gap-x-6 gap-y-1.5 @min-[560px]:grid-cols-1 @min-[560px]:text-right">
                <div>
                  <dt className="font-mono text-[10.5px] uppercase tracking-wider text-mute">Issued</dt>
                  <dd className="mt-1">{issued}</dd>
                </div>
                <div>
                  <dt className="font-mono text-[10.5px] uppercase tracking-wider text-mute">{paid ? "Paid" : "Due"}</dt>
                  <dd key={paid ? "p" : "d"} className={cx("mt-1", paid && "asta-invoice-a animate-[asta-invoice-in_.4s_cubic-bezier(.16,1,.3,1)_both] text-brand")}>
                    {paid ? (paidOn ?? due) : due}
                  </dd>
                </div>
              </dl>
            </div>
    
            {/* Line items */}
            <div>
              <div className="hidden grid-cols-[1fr_56px_96px_104px] gap-4 px-1 pb-2 font-mono text-[10.5px] uppercase tracking-wider text-mute @min-[560px]:grid" aria-hidden>
                <span>Item</span>
                <span className="text-right">Qty</span>
                <span className="text-right">Price</span>
                <span className="text-right">Amount</span>
              </div>
              <ul className="flex flex-col">
                {items.map((it, i) => (
                  <li
                    key={it.description + i}
                    className="grid grid-cols-[1fr_auto] gap-x-4 gap-y-0.5 rounded-lg px-1 py-2.5 text-[13.5px] odd:bg-paper-2 @min-[560px]:grid-cols-[1fr_56px_96px_104px] @min-[560px]:items-center @min-[560px]:px-3"
                  >
                    <div className="min-w-0">
                      <p className="font-medium">{it.description}</p>
                      {it.detail && <p className="text-[12px] text-mute">{it.detail}</p>}
                      <p className="text-[12px] tabular-nums text-mute @min-[560px]:hidden">
                        {it.quantity} × {money(it.unitPrice)}
                      </p>
                    </div>
                    <span className="hidden text-right tabular-nums text-ink-2 @min-[560px]:block">{it.quantity}</span>
                    <span className="hidden text-right tabular-nums text-ink-2 @min-[560px]:block">{money(it.unitPrice)}</span>
                    <span className="text-right font-medium tabular-nums">{money(it.quantity * it.unitPrice)}</span>
                  </li>
                ))}
              </ul>
            </div>
    
            {/* Totals */}
            <dl className="ml-auto flex w-full max-w-[300px] flex-col gap-1.5 text-[13px]">
              <div className="flex justify-between gap-4">
                <dt className="text-mute">Subtotal</dt>
                <dd className="tabular-nums">{money(subtotal)}</dd>
              </div>
              {discount > 0 && (
                <div className="flex justify-between gap-4">
                  <dt className="text-mute">Discount</dt>
                  <dd className="tabular-nums">−{money(discount)}</dd>
                </div>
              )}
              {taxRate > 0 && (
                <div className="flex justify-between gap-4">
                  <dt className="text-mute">Tax ({Math.round(taxRate * 1000) / 10}%)</dt>
                  <dd className="tabular-nums">{money(tax)}</dd>
                </div>
              )}
              <div className="mt-1.5 flex items-baseline justify-between gap-4 pt-1.5">
                <dt className="font-medium">Total</dt>
                <dd className="text-[22px] font-medium tracking-[-0.03em] tabular-nums">{money(total)}</dd>
              </div>
              <div className="flex justify-between gap-4">
                <dt className="text-mute">Amount due</dt>
                <dd key={paid ? "p" : "d"} className={cx("font-medium tabular-nums", paid && "asta-invoice-a animate-[asta-invoice-in_.4s_cubic-bezier(.16,1,.3,1)_both] text-brand")}>
                  {money(paid ? 0 : total)}
                </dd>
              </div>
            </dl>
    
            {/* Footer */}
            {(notes || onPay || onDownload) && (
              <footer className="flex flex-col gap-4 @min-[560px]:flex-row @min-[560px]:items-end @min-[560px]:justify-between">
                {notes ? <div className="max-w-[360px] text-[12.5px] leading-relaxed text-mute">{notes}</div> : <span />}
                <div className="flex flex-wrap gap-2 @max-[559px]:[&>*]:flex-1">
                  {onDownload && (
                    <Button variant="outline" size="sm" onClick={onDownload}>
                      Download PDF
                    </Button>
                  )}
                  {onPay && !paid && state !== "draft" && (
                    <Button variant="accent" size="sm" loading={paying} onClick={pay}>
                      Pay {money(total)}
                    </Button>
                  )}
                </div>
              </footer>
            )}
            {error && !paid && (
              <p ref={errorEl} role="alert" tabIndex={-1} className="-mt-3 flex items-start gap-1.5 text-[12.5px] font-medium text-ink outline-none @min-[560px]:justify-end">
                <svg viewBox="0 0 24 24" className="mt-px h-3.5 w-3.5 shrink-0" fill="none" stroke="currentColor" strokeWidth="2.4" strokeLinecap="round" strokeLinejoin="round" aria-hidden>
                  <path d="M10.3 4.6 3 17.5A2 2 0 0 0 4.7 20.5h14.6a2 2 0 0 0 1.7-3L13.7 4.6a2 2 0 0 0-3.4 0Z" />
                  <path d="M12 9.5v4" />
                  <path d="M12 17h.01" />
                </svg>
                {error}
              </p>
            )}
            <p className="sr-only" aria-live="polite">
              {paid && paidOn ? `Invoice ${number} paid on ${paidOn}.` : ""}
            </p>
          </div>
        </article>
      );
    }
    
    export default Invoice;
    
    "use client";
    
    import { useEffect, useMemo, useRef, useState, type ReactNode } from "react";
    import { Button } from "@/components/kit/base/button";
    
    const cx = (...c: (string | false | null | undefined)[]) => c.filter(Boolean).join(" ");
    
    const KEYFRAMES = `@keyframes asta-invoice-in { from { opacity: 0; transform: translateY(4px) } }
    @keyframes asta-invoice-draw { from { stroke-dashoffset: 1 } }
    @keyframes asta-invoice-pop { 0% { transform: scale(.6); opacity: 0 } 60% { transform: scale(1.08) } 100% { transform: none; opacity: 1 } }
    @media (prefers-reduced-motion: reduce) { .asta-invoice-a { animation: none !important } }`;
    
    export type InvoiceStatus = "draft" | "due" | "overdue" | "paid";
    
    export interface InvoiceLine {
      description: string;
      /** A muted second line, e.g. the period it covers. */
      detail?: string;
      quantity: number;
      unitPrice: number;
    }
    
    export interface InvoiceParty {
      name: string;
      /** Address, email, tax id: one per line. */
      lines: string[];
    }
    
    export interface InvoiceProps {
      number: string;
      /** Already formatted dates, e.g. "Nov 1, 2026". */
      issued: string;
      due: string;
      from: InvoiceParty;
      to: InvoiceParty;
      items: InvoiceLine[];
      /** e.g. 0.11 for 11%. */
      taxRate?: number;
      /** An amount taken off before tax. */
      discount?: number;
      currency?: string;
      locale?: string;
      status?: InvoiceStatus;
      notes?: ReactNode;
      /** Logo or wordmark at the top left. */
      brand?: ReactNode;
      /** Shows Pay. Resolve to mark it paid, throw to stay due. */
      onPay?: () => Promise<void> | void;
      /** Shows Download. */
      onDownload?: () => void;
      className?: string;
    }
    
    const STATUS: Record<InvoiceStatus, { label: string; cls: string }> = {
      draft: { label: "Draft", cls: "text-mute shadow-[inset_0_0_0_1px_color-mix(in_srgb,var(--color-ink)_16%,transparent)]" },
      due: { label: "Due", cls: "bg-paper-2 text-ink" },
      overdue: { label: "Overdue", cls: "bg-ink text-paper" },
      paid: { label: "Paid", cls: "bg-[color-mix(in_srgb,var(--color-brand)_12%,transparent)] text-brand" },
    };
    
    /**
     * An invoice: who it's from and to, line items, tax and the total. Pay shows a pending state, then the status
     * turns to Paid, the amount due drops to zero and a check draws itself in. Wrap it in nothing: it sets its own
     * container, so line items stack when the card is narrow, not the window.
     */
    export function Invoice({ number, issued, due, from, to, items, taxRate = 0, discount = 0, currency = "USD", locale = "en-US", status = "due", notes, brand, onPay, onDownload, className }: InvoiceProps) {
      const [state, setState] = useState<InvoiceStatus>(status);
      const [paying, setPaying] = useState(false);
      const [paidOn, setPaidOn] = useState<string | null>(null);
      const [error, setError] = useState<string | null>(null);
      const errorEl = useRef<HTMLParagraphElement>(null);
      // A failed payment moves focus to the message, so keyboard and screen reader users hear it.
      useEffect(() => {
        if (error) errorEl.current?.focus();
      }, [error]);
      // One formatter per locale and currency. Building one per call cost ~70ms on a throttled phone.
      const money = useMemo(() => {
        const f = new Intl.NumberFormat(locale, { style: "currency", currency });
        return (n: number) => f.format(n);
      }, [locale, currency]);
    
      const subtotal = items.reduce((a, it) => a + it.quantity * it.unitPrice, 0);
      const taxed = Math.max(0, subtotal - discount);
      const tax = Math.round(taxed * taxRate * 100) / 100;
      const total = taxed + tax;
      const paid = state === "paid";
      const s = STATUS[state];
    
      const pay = async () => {
        if (!onPay || paying) return;
        setPaying(true);
        setError(null);
        try {
          await onPay();
          setPaidOn(new Date().toLocaleDateString(locale, { month: "short", day: "numeric", year: "numeric" }));
          setState("paid");
        } catch (e) {
          const why = e instanceof Error && e.message ? ` ${e.message.replace(/\.?$/, ".")}` : "";
          setError(`The payment didn't go through.${why} Check your payment details and try again.`);
        } finally {
          setPaying(false);
        }
      };
    
      return (
        <article
          aria-label={`Invoice ${number}`}
          className={cx("@container w-full rounded-[14px] bg-paper text-ink shadow-[inset_0_0_0_1px_color-mix(in_srgb,var(--color-ink)_10%,transparent),0_18px_44px_-28px_rgb(0_0_0/0.3)]", className)}
        >
          <style href="asta-invoice" precedence="asta">{KEYFRAMES}</style>
          <div className="flex flex-col gap-7 p-5 @min-[560px]:p-8">
            {/* Head */}
            <header className="flex flex-wrap items-start justify-between gap-4">
              <div className="min-w-0">{brand ?? <p className="text-[17px] font-semibold tracking-[-0.03em]">{from.name}</p>}</div>
              <div className="flex flex-col items-end gap-1.5 text-right">
                <div className="flex items-center gap-2">
                  <h2 className="text-[20px] font-medium tracking-[-0.03em]">Invoice</h2>
                  <span key={state} className={cx("asta-invoice-a inline-flex h-6 animate-[asta-invoice-pop_.45s_cubic-bezier(.16,1,.3,1)_both] items-center gap-1 rounded-md px-2 text-[11.5px] font-medium", s.cls)}>
                    {paid ? (
                      <svg viewBox="0 0 24 24" className="h-3 w-3" fill="none" stroke="currentColor" strokeWidth="3.3" strokeLinecap="round" strokeLinejoin="round" aria-hidden>
                        <path d="m5 12.5 4.5 4.5L19 7.5" pathLength={1} strokeDasharray={1} className="asta-invoice-a animate-[asta-invoice-draw_.5s_cubic-bezier(.16,1,.3,1)_.15s_both]" />
                      </svg>
                    ) : state === "overdue" ? (
                      <svg viewBox="0 0 24 24" className="h-3 w-3" fill="none" stroke="currentColor" strokeWidth="2.7" strokeLinecap="round" aria-hidden>
                        <path d="M12 7.5v5" />
                        <path d="M12 16h.01" />
                      </svg>
                    ) : null}
                    {s.label}
                  </span>
                </div>
                <p className="font-mono text-[12px] text-mute">{number}</p>
              </div>
            </header>
    
            {/* Parties and dates */}
            <div className="grid gap-5 text-[13px] @min-[560px]:grid-cols-[1fr_1fr_auto] @min-[560px]:gap-8">
              {[
                ["Billed to", to],
                ["From", from],
              ].map(([title, p]) => {
                const party = p as InvoiceParty;
                return (
                  <div key={title as string} className="min-w-0">
                    <p className="font-mono text-[10.5px] uppercase tracking-wider text-mute">{title as string}</p>
                    <p className="mt-1.5 font-medium">{party.name}</p>
                    {party.lines.map((l) => (
                      <p key={l} className="text-mute">
                        {l}
                      </p>
                    ))}
                  </div>
                );
              })}
              <dl className="grid grid-cols-2 gap-x-6 gap-y-1.5 @min-[560px]:grid-cols-1 @min-[560px]:text-right">
                <div>
                  <dt className="font-mono text-[10.5px] uppercase tracking-wider text-mute">Issued</dt>
                  <dd className="mt-1">{issued}</dd>
                </div>
                <div>
                  <dt className="font-mono text-[10.5px] uppercase tracking-wider text-mute">{paid ? "Paid" : "Due"}</dt>
                  <dd key={paid ? "p" : "d"} className={cx("mt-1", paid && "asta-invoice-a animate-[asta-invoice-in_.4s_cubic-bezier(.16,1,.3,1)_both] text-brand")}>
                    {paid ? (paidOn ?? due) : due}
                  </dd>
                </div>
              </dl>
            </div>
    
            {/* Line items */}
            <div>
              <div className="hidden grid-cols-[1fr_56px_96px_104px] gap-4 px-1 pb-2 font-mono text-[10.5px] uppercase tracking-wider text-mute @min-[560px]:grid" aria-hidden>
                <span>Item</span>
                <span className="text-right">Qty</span>
                <span className="text-right">Price</span>
                <span className="text-right">Amount</span>
              </div>
              <ul className="flex flex-col">
                {items.map((it, i) => (
                  <li
                    key={it.description + i}
                    className="grid grid-cols-[1fr_auto] gap-x-4 gap-y-0.5 rounded-lg px-1 py-2.5 text-[13.5px] odd:bg-paper-2 @min-[560px]:grid-cols-[1fr_56px_96px_104px] @min-[560px]:items-center @min-[560px]:px-3"
                  >
                    <div className="min-w-0">
                      <p className="font-medium">{it.description}</p>
                      {it.detail && <p className="text-[12px] text-mute">{it.detail}</p>}
                      <p className="text-[12px] tabular-nums text-mute @min-[560px]:hidden">
                        {it.quantity} × {money(it.unitPrice)}
                      </p>
                    </div>
                    <span className="hidden text-right tabular-nums text-ink-2 @min-[560px]:block">{it.quantity}</span>
                    <span className="hidden text-right tabular-nums text-ink-2 @min-[560px]:block">{money(it.unitPrice)}</span>
                    <span className="text-right font-medium tabular-nums">{money(it.quantity * it.unitPrice)}</span>
                  </li>
                ))}
              </ul>
            </div>
    
            {/* Totals */}
            <dl className="ml-auto flex w-full max-w-[300px] flex-col gap-1.5 text-[13px]">
              <div className="flex justify-between gap-4">
                <dt className="text-mute">Subtotal</dt>
                <dd className="tabular-nums">{money(subtotal)}</dd>
              </div>
              {discount > 0 && (
                <div className="flex justify-between gap-4">
                  <dt className="text-mute">Discount</dt>
                  <dd className="tabular-nums">−{money(discount)}</dd>
                </div>
              )}
              {taxRate > 0 && (
                <div className="flex justify-between gap-4">
                  <dt className="text-mute">Tax ({Math.round(taxRate * 1000) / 10}%)</dt>
                  <dd className="tabular-nums">{money(tax)}</dd>
                </div>
              )}
              <div className="mt-1.5 flex items-baseline justify-between gap-4 pt-1.5">
                <dt className="font-medium">Total</dt>
                <dd className="text-[22px] font-medium tracking-[-0.03em] tabular-nums">{money(total)}</dd>
              </div>
              <div className="flex justify-between gap-4">
                <dt className="text-mute">Amount due</dt>
                <dd key={paid ? "p" : "d"} className={cx("font-medium tabular-nums", paid && "asta-invoice-a animate-[asta-invoice-in_.4s_cubic-bezier(.16,1,.3,1)_both] text-brand")}>
                  {money(paid ? 0 : total)}
                </dd>
              </div>
            </dl>
    
            {/* Footer */}
            {(notes || onPay || onDownload) && (
              <footer className="flex flex-col gap-4 @min-[560px]:flex-row @min-[560px]:items-end @min-[560px]:justify-between">
                {notes ? <div className="max-w-[360px] text-[12.5px] leading-relaxed text-mute">{notes}</div> : <span />}
                <div className="flex flex-wrap gap-2 @max-[559px]:[&>*]:flex-1">
                  {onDownload && (
                    <Button variant="outline" size="sm" onClick={onDownload}>
                      Download PDF
                    </Button>
                  )}
                  {onPay && !paid && state !== "draft" && (
                    <Button variant="accent" size="sm" loading={paying} onClick={pay}>
                      Pay {money(total)}
                    </Button>
                  )}
                </div>
              </footer>
            )}
            {error && !paid && (
              <p ref={errorEl} role="alert" tabIndex={-1} className="-mt-3 flex items-start gap-1.5 text-[12.5px] font-medium text-ink outline-none @min-[560px]:justify-end">
                <svg viewBox="0 0 24 24" className="mt-px h-3.5 w-3.5 shrink-0" fill="none" stroke="currentColor" strokeWidth="2.4" strokeLinecap="round" strokeLinejoin="round" aria-hidden>
                  <path d="M10.3 4.6 3 17.5A2 2 0 0 0 4.7 20.5h14.6a2 2 0 0 0 1.7-3L13.7 4.6a2 2 0 0 0-3.4 0Z" />
                  <path d="M12 9.5v4" />
                  <path d="M12 17h.01" />
                </svg>
                {error}
              </p>
            )}
            <p className="sr-only" aria-live="polite">
              {paid && paidOn ? `Invoice ${number} paid on ${paidOn}.` : ""}
            </p>
          </div>
        </article>
      );
    }
    
    export default Invoice;
    
  4. Or ask your AI agent

    Paste this into Claude Code, Cursor, Codex, v0 or Lovable. Fill in the last line. More in Prompts.

    Add the Astabyte UI Invoice component to my project.
    
    Line items, tax, total and a pay button.
    It includes: line items, totals, status, pay, download, responsive.
    
    Install it (Radix build):
    ```sh
    pnpm dlx asta-ui@latest add invoice --radix
    ```
    Or with the shadcn CLI:
    ```sh
    pnpm dlx shadcn@latest add https://ui.astabyte.com/r/invoice.json
    ```
    If the project isn't set up yet, run `pnpm dlx asta-ui@latest init --radix` first: it runs `shadcn init` when needed and adds the @astabyte registry (Next.js, Vite, React Router, Astro, TanStack Start; Tailwind CSS v4).
    
    Import it like this:
    ```tsx
    import { Invoice } from "@/components/astabyte/invoice";
    ```
    
    Usage example and props: https://ui.astabyte.com/invoice
    Full catalogue for context: https://ui.astabyte.com/llms.txt
    
    Rules:
    - Keep the colour tokens (paper, paper-2, ink, ink-2, mute, brand). Don't restyle with hard-coded colours; rebrand by changing the token values in the CSS.
    - Keep the motion as it is: transform and opacity only, and the prefers-reduced-motion fallback.
    - Keep keyboard, focus and ARIA behaviour (interactive pieces are built on Radix primitives from the radix-ui package).
    - Stay on Radix: install other Astabyte UI components with `--radix` so the project uses one primitive library.
    - Use fake data and fake brand names in examples.
    
    Use it to: [describe where it goes and what it should do]
    Add the Astabyte UI Invoice component to my project.
    
    Line items, tax, total and a pay button.
    It includes: line items, totals, status, pay, download, responsive.
    
    Install it (Base UI build):
    ```sh
    pnpm dlx asta-ui@latest add invoice
    ```
    Or with the shadcn CLI:
    ```sh
    pnpm dlx shadcn@latest add https://ui.astabyte.com/r/base/invoice.json
    ```
    If the project isn't set up yet, run `pnpm dlx asta-ui@latest init` first: it runs `shadcn init` when needed and adds the @astabyte registry (Next.js, Vite, React Router, Astro, TanStack Start; Tailwind CSS v4).
    
    Import it like this:
    ```tsx
    import { Invoice } from "@/components/astabyte/invoice";
    ```
    
    Usage example and props: https://ui.astabyte.com/invoice
    Full catalogue for context: https://ui.astabyte.com/llms.txt
    
    Rules:
    - Keep the colour tokens (paper, paper-2, ink, ink-2, mute, brand). Don't restyle with hard-coded colours; rebrand by changing the token values in the CSS.
    - Keep the motion as it is: transform and opacity only, and the prefers-reduced-motion fallback.
    - Keep keyboard, focus and ARIA behaviour (interactive pieces are built on Base UI primitives from the @base-ui/react package).
    - Stay on Base UI: install other Astabyte UI components without `--radix` so the project uses one primitive library.
    - Use fake data and fake brand names in examples.
    
    Use it to: [describe where it goes and what it should do]
  5. Or use plain HTML + CSS

    Not on React? Use it from Django, Rails, Laravel, Go html/template, htmx or a static page. Load asta.css and asta.js once (the head.html tab), then paste the markup. The ui.astabyte.com/cdn link is temporary: pin a version from jsDelivr for production. More in HTML + CSS.

    <!-- Static. Swap the status class (asta-invoice-status-paid, -overdue, -draft) from your server after payment. -->
    <article class="asta-invoice" aria-label="Invoice INV-2026-0142" style="max-width:760px">
    <header class="asta-invoice-head"><p style="font-size:17px;font-weight:600;letter-spacing:-0.03em">Astabyte</p><div><h2 class="asta-invoice-title">Invoice <span class="asta-invoice-status">Due</span></h2><p class="asta-invoice-number">INV-2026-0142</p></div></header>
    <div class="asta-invoice-parties">
    <div><p class="asta-invoice-label">Billed to</p><b>Juniper Goods Co.</b>88 Harbor Street, Singapore<br>[email protected]</div>
    <div><p class="asta-invoice-label">From</p><b>Astabyte Studio</b>Jl. Senopati 18, Jakarta<br>[email protected]</div>
    <div><p class="asta-invoice-label">Issued</p><b style="margin-top:4px">Nov 1, 2026</b><p class="asta-invoice-label" style="margin-top:8px">Due</p><b style="margin-top:4px">Nov 15, 2026</b></div>
    </div>
    <table class="asta-invoice-items"><thead><tr><th>Item</th><th class="asta-invoice-num">Qty</th><th class="asta-invoice-num">Price</th><th>Amount</th></tr></thead><tbody>
    <tr><td>Product design sprint<small>Two weeks, Oct 6 – Oct 17</small></td><td class="asta-invoice-num">1</td><td class="asta-invoice-num">$6,400.00</td><td>$6,400.00</td></tr>
    <tr><td>Design system setup<small>Tokens, components, docs</small></td><td class="asta-invoice-num">1</td><td class="asta-invoice-num">$3,200.00</td><td>$3,200.00</td></tr>
    <tr><td>Frontend build<small>Hours</small></td><td class="asta-invoice-num">36</td><td class="asta-invoice-num">$95.00</td><td>$3,420.00</td></tr>
    <tr><td>Hosting and monitoring<small>November</small></td><td class="asta-invoice-num">1</td><td class="asta-invoice-num">$180.00</td><td>$180.00</td></tr>
    </tbody></table>
    <dl class="asta-invoice-totals"><dt>Subtotal</dt><dd>$13,200.00</dd><dt>Discount</dt><dd>−$500.00</dd><dt>Tax (11%)</dt><dd>$1,397.00</dd><dt class="asta-invoice-total">Total</dt><dd>$14,097.00</dd><dt>Amount due</dt><dd>$14,097.00</dd></dl>
    <footer class="asta-invoice-foot"><p>Thanks for working with us. Bank transfer details are on page two of the PDF.</p><div style="display:flex;gap:8px"><button type="button" class="asta-btn asta-btn-outline asta-btn-sm"><span class="asta-btn-label">Download PDF</span></button><button type="button" class="asta-btn asta-btn-accent asta-btn-sm" hx-post="/invoices/0142/pay"><span class="asta-btn-label">Pay $14,097.00</span></button></div></footer>
    </article>

Usage

The demo above, as code.

"use client";

import { useState } from "react";
import { Invoice } from "@/components/astabyte/invoice";

export default function InvoiceDemo() {
  const [round, setRound] = useState(0);
  const [note, setNote] = useState("");

  return (
    <div className="flex min-h-[640px] w-full flex-col items-center justify-center gap-3 p-3 sm:p-8">
      <Invoice
        key={round}
        className="max-w-[760px]"
        number="INV-2026-0142"
        issued="Nov 1, 2026"
        due="Nov 15, 2026"
        brand={
          <p className="flex items-center gap-2 text-[16px] font-semibold tracking-[-0.03em]">
            <span className="grid h-6 w-6 place-items-center rounded-md bg-ink text-[11px] text-paper">
              A
            </span>
            Astabyte
          </p>
        }
        from={{
          name: "Astabyte Studio",
          lines: ["Jl. Senopati 18, Jakarta", "[email protected]"],
        }}
        to={{
          name: "Juniper Goods Co.",
          lines: ["88 Harbor Street, Singapore", "[email protected]"],
        }}
        items={[
          {
            description: "Product design sprint",
            detail: "Two weeks, Oct 6 – Oct 17",
            quantity: 1,
            unitPrice: 6400,
          },
          {
            description: "Design system setup",
            detail: "Tokens, components, docs",
            quantity: 1,
            unitPrice: 3200,
          },
          {
            description: "Frontend build",
            detail: "Hours",
            quantity: 36,
            unitPrice: 95,
          },
          {
            description: "Hosting and monitoring",
            detail: "November",
            quantity: 1,
            unitPrice: 180,
          },
        ]}
        discount={500}
        taxRate={0.11}
        notes="Thanks for working with us. Bank transfer details are on page two of the PDF."
        onDownload={() => setNote("PDF download started (demo).")}
        onPay={() => new Promise((r) => setTimeout(r, 1300))}
      />
      <p
        className="flex h-6 items-center gap-3 text-[12.5px] text-mute"
        aria-live="polite"
      >
        {note}
        <button
          type="button"
          className="text-ink underline decoration-[color-mix(in_srgb,var(--color-ink)_30%,transparent)] underline-offset-2"
          onClick={() => {
            setRound((r) => r + 1);
            setNote("");
          }}
        >
          Reset
        </button>
      </p>
    </div>
  );
}