EntityMark
- Status
- Implemented
- Family
- 1 of 13
- Registry
- @lopifi/entity-mark
npx shadcn@latest add @lopifi/theme @lopifi/entity-markThe component, rendering
Real data, the shipped component. Switch the theme to check the claims the spec makes below.
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.
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
- MoneyThe core primitive. A monetary value, formatted correctly.
- DeltaA signed change, with polarity and a redundant non-color cue.
- FigureA large display numeral with automatic size step-down.
- PercentPercent vs. percentage points, explicitly discriminated.
- RuleSingle / double / section accounting rule lines.
- StatusPillPayment and reconciliation states.
- SparklineInline trend, one-shot draw.
- TrendArrow + delta + optional sparkline, composed.
- AsOfTimestamp with live relative formatting and a stated timezone.
- RedactedMasked value with reveal.
- ReferenceCopyable transaction/account ID with disambiguated glyphs.
- CurrencyBadgeISO code + optional flag.
- TooltipHover/focus restatement. Never the only home of a fact.
- InfoTipThe ⓘ. Extra context that survives touch, because it opens on press.
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.
- EntityMark, runningThe primitives showcase — live, with theme, density, greyscale and reduced-motion switches.Live
- Tenancy and multi-entityWhat is the boundary of one set of books?API
- PrimitivesBuild these first. Everything above them inherits their mistakes. Specs for 15 React components: Money, Delta, Figure, Percent and 11 more.Doc
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.