Skip to main content

MaskedField

A sensitive value rendered redacted by default, with optional reveal and copy affordances. Revealing is always an explicit user action; it is reported through onReveal, and the value hides itself again when focus leaves the field.

Signature
Density
Viewport
Theme and light/dark are set in the top bar
Live demo
Open ↗

When to use​

A sensitive value rendered redacted by default, with optional reveal and copy affordances.

Accessibility​

Masked values stay obscured to assistive tech until revealed; the reveal toggle is a labelled button. Audit entries are an ordered list.

Install and import​

npx shadcn@latest add @prism/masked-field
import { MaskedField } from '@/components/prism/MaskedField';

In a no-build prototype, read it from the bundle instead: const { MaskedField } = window.PrismDesignSystem_39d121;

Props​

PropTypeRequiredDescription
valuestring | numberYesThe sensitive value to display (string or number).
labelReact.ReactNode—Optional caption above the value.
visibleCharsnumber—How many trailing characters stay visible when masked. Default 4.
maskCharstring—Character used for the mask. Default "•".
revealableboolean—Show the reveal/hide toggle. Default true.
copyableboolean—Show a copy-to-clipboard button. Default false.
defaultRevealedboolean—Start revealed. Default false.
remaskOnBlurboolean—Hide the value again when focus leaves the field. Default true.
remaskAfternumber—Hide the value again this many milliseconds after it is revealed. Default: no timer.
onReveal() => void—Called each time the value is revealed. Write the access to your audit log here.
onRevealChange(revealed: boolean) => void—Called whenever the value is revealed (true) or hidden again (false).
classNamestring—