Skip to content

EntityMark

Bank/merchant logo with the full fallback ladder.
Implemented
Status
Implemented
Family
1 of 13
Registry
@lopifi/entity-mark
npx shadcn@latest add @lopifi/theme @lopifi/entity-mark

The component, rendering

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

Preview

The four-layer spec

Bank and merchant logos. Rounded-square container at radius 8, --surface-sunken background, ~20% inset, object-fit: contain, saturate(0.85) at row scale. Full fallback ladder — provided → resolved → deterministic monogram → category icon. Never a broken image. Spec in imagery.

Lifted verbatim from Primitives. 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/entity-mark.tsx

Lopifi dependencies · 2
cnicons
npm packages
clsxtailwind-merge
Registry entry
/r/entity-mark.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/entity-mark.tsx
import * as React from "react";
import { cn } from "@/lib/ledger/cn";
import { BuildingLibraryIcon, BuildingOffice2Icon, CreditCardIcon, ShoppingBagIcon } from "@/components/ledger/icons";

type Category = "bank" | "merchant" | "card" | "company";

const CATEGORY_ICON = {
  bank: BuildingLibraryIcon,
  card: CreditCardIcon,
  company: BuildingOffice2Icon,
  merchant: ShoppingBagIcon,
} as const;

export interface EntityMarkProps extends React.ComponentPropsWithoutRef<"div"> {
  category?: Category;
  name: string;
  size?: 20 | 24 | 32 | 40 | 48;
  src?: string;
}

/**
 * The full fallback ladder — provided → deterministic monogram → category
 * icon. Never a broken image.
 */
export const EntityMark = React.forwardRef<HTMLDivElement, EntityMarkProps>(
  ({ className, name, src, category = "merchant", size = 32, ...props }, ref) => {
    const Icon = CATEGORY_ICON[category];
    const monogram = initials(name);

    return (
      <div
        aria-hidden="true"
        className={cn(
          "grid shrink-0 place-items-center overflow-hidden rounded-sm bg-surface-sunken",
          "border border-border-subtle",
          className,
        )}
        ref={ref}
        style={{ height: size, width: size }}
        title={name}
        {...props}
      >
        {src ? (
          // eslint-disable-next-line @next/next/no-img-element
          <img alt="" className="size-full object-contain p-[20%] [filter:saturate(0.85)]" src={src} />
        ) : monogram ? (
          <span className="font-medium text-text-secondary" style={{ fontSize: Math.round(size * 0.38) }}>
            {monogram}
          </span>
        ) : (
          <Icon className="text-text-tertiary" style={{ height: size * 0.5, width: size * 0.5 }} />
        )}
      </div>
    );
  },
);
EntityMark.displayName = "EntityMark";

function initials(name: string): string {
  const words = name.trim().split(/\s+/).filter(Boolean);
  if (words.length === 0) return "";
  if (words.length === 1) return words[0].slice(0, 2).toUpperCase();
  return (words[0][0] + words[1][0]).toUpperCase();
}

Also in Primitives

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 EntityMark 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 Primitives 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.