Skip to content

Redacted

Masked value with reveal.
Implemented
Status
Implemented
Family
1 of 13
Registry
@lopifi/redacted
npx shadcn@latest add @lopifi/theme @lopifi/redacted

The component, rendering

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

Preview

The four-layer spec

•••• at --text-tertiary, reveal on explicit action. Layout-stable: the masked form reserves the revealed width. Privacy-blur variant uses filter: blur(6px) + user-select: none, crossfading over 140ms so nothing reflows.

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/redacted.tsx

Lopifi dependencies · 2
cnicons
npm packages
clsxtailwind-merge
Registry entry
/r/redacted.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/redacted.tsx
"use client";

import * as React from "react";
import { cn } from "@/lib/ledger/cn";
import { EyeIcon, EyeSlashIcon } from "@/components/ledger/icons";

export interface RedactedProps extends React.ComponentPropsWithoutRef<"span"> {
  children: React.ReactNode;
  defaultRevealed?: boolean;
  label?: string;
  /** Blur the real value instead of masking it. Layout-identical either way. */
  mode?: "mask" | "blur";
}

/**
 * Redaction is a presentation state, not missing data.
 *
 * The masked form reserves the revealed width so nothing reflows, and the
 * blur variant keeps `user-select: none` so the value can't be copied out
 * of a "hidden" state.
 */
export const Redacted = React.forwardRef<HTMLSpanElement, RedactedProps>(
  ({ className, children, mode = "blur", label = "Balance", defaultRevealed = false, ...props }, ref) => {
    const [revealed, setRevealed] = React.useState(defaultRevealed);

    return (
      <span className={cn("inline-flex items-center gap-2", className)} ref={ref} {...props}>
        <span
          aria-hidden={!revealed}
          className={cn(
            "transition-[filter,opacity] duration-2 ease-out",
            !revealed && mode === "blur" && "select-none blur-[6px]",
            !revealed && mode === "mask" && "invisible",
          )}
        >
          {children}
        </span>
        {!revealed && mode === "mask" ? (
          <span aria-hidden="true" className="absolute text-text-tertiary">
            ••••
          </span>
        ) : null}
        <button
          aria-label={revealed ? `${label} shown, activate to hide` : `${label} hidden, activate to reveal`}
          aria-pressed={revealed}
          className={cn(
            "grid size-8 shrink-0 place-items-center rounded-sm text-text-tertiary",
            "transition-colors duration-1 ease-standard",
            "@media(hover:hover)and(pointer:fine){hover:bg-surface-hover}",
            "hover:bg-surface-hover hover:text-text-secondary",
          )}
          onClick={() => setRevealed((v) => !v)}
          type="button"
        >
          {revealed ? (
            <EyeSlashIcon aria-hidden="true" className="size-4" />
          ) : (
            <EyeIcon aria-hidden="true" className="size-4" />
          )}
        </button>
      </span>
    );
  },
);
Redacted.displayName = "Redacted";

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