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 barWhen 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
| Prop | Type | Required | Description |
|---|---|---|---|
value | string | number | Yes | The sensitive value to display (string or number). |
label | React.ReactNode | — | Optional caption above the value. |
visibleChars | number | — | How many trailing characters stay visible when masked. Default 4. |
maskChar | string | — | Character used for the mask. Default "•". |
revealable | boolean | — | Show the reveal/hide toggle. Default true. |
copyable | boolean | — | Show a copy-to-clipboard button. Default false. |
defaultRevealed | boolean | — | Start revealed. Default false. |
remaskOnBlur | boolean | — | Hide the value again when focus leaves the field. Default true. |
remaskAfter | number | — | 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). |
className | string | — |