Tac UIv1.1.2

SensitiveInput

A secure input that masks its value by default and reveals on explicit user action. Supports copy-without-reveal and keyboard-driven state transitions.

Import

tsx
import { SensitiveInput } from '@tac-ui/web';

Playground

Interactively configure the SensitiveInput props below.

Value is hidden
tsx
<SensitiveInput
  value={value}
  onChange={(e) => setValue(e.target.value)}
  placeholder="Enter a secret value"
/>

Default (Pre-filled Value)

When a value is provided, the component starts in the masked state showing bullet characters. Click or press Enter/Space to reveal the actual value.

Value is hidden
tsx
const [value, setValue] = useState('sk-proj-aBcDeFgHiJkLmNoPqRsTuVwXyZ');

<SensitiveInput
  value={value}
  onChange={(e) => setValue(e.target.value)}
/>

Empty State

When no value is provided, the input renders as a standard text field. Once a value is entered and the component is remounted, it starts in the masked state.

tsx
const [value, setValue] = useState('');

<SensitiveInput
  value={value}
  onChange={(e) => setValue(e.target.value)}
  placeholder="Type a secret here..."
/>

Disabled

A disabled SensitiveInput is non-interactive with reduced opacity.

Value is hidden
tsx
<SensitiveInput value="disabled-secret-value" disabled />

With Label

Compose with the Label component by passing a matching id and htmlFor for accessible labelling.

Value is hidden
tsx
<div className="flex flex-col gap-1.5 w-full">
  <Label htmlFor="api-key-input">API Key</Label>
  <SensitiveInput
    id="api-key-input"
    value={value}
    onChange={(e) => setValue(e.target.value)}
  />
</div>

Keyboard Navigation

SensitiveInput is fully keyboard accessible with the following shortcuts:

Value is hidden
tsx
// Masked state:
// Enter or Space → reveals the value
// Tab → moves focus normally

// Revealed state:
// Escape → re-masks the value

// Hover on mask → shows copy button

API Reference

PropTypeDefaultDescription
valuestring-Controlled value. When non-empty, the component starts in the masked state.
defaultValuestring-Uncontrolled default value.
placeholderstring-Placeholder text shown in the empty state.
onCopy() => void-Called after the value is copied to clipboard from the masked state.
onReveal() => void-Called when the input transitions from masked to revealed.
onChangeChangeEventHandler<HTMLInputElement>-Standard input change handler.
onKeyDownKeyboardEventHandler<HTMLInputElement>-Keyboard handler. Escape is intercepted to re-mask; others are forwarded.
disabledbooleanfalseDisables the input.
idstring-HTML id for the input. Auto-generated if not provided.
classNamestring-Additional CSS class names.