Skip to content

Sensitive Input

A password or token field: masked by default, with a button that reveals it and an optional one that copies it.

1.3 kB gzipSource Registry JSON

SensitiveInput playground

Props

Installation

npx shadcn@latest add https://sproutboat.com/ikada/r/sensitive-input.json

The CLI writes components/ikada/sensitive-input.tsx and merges the ikada theme into your CSS. It also installs the components it is built from: Icon Button, Inline Confirm and Input. Or take it from the package: import { SensitiveInput } from "@sproutboat/ikada";

Usage

import { SensitiveInput } from "@/components/ikada/sensitive-input";

<SensitiveInput aria-label="API token" defaultValue="sb_live_2f9a41c7" copyable mono />

Examples

In a Field

Masked until the eye button is pressed. The label and description are wired by Field.

Shown once. Store it somewhere safe.

Copyable

The copy button copies the real value even while it is masked.

Revealed

Error

Use at least 12 characters.

Disabled

Props

SensitiveInputProps
PropTypeDescription
copyablebooleanShows a copy button. It copies the real value even while it is masked. Default `false`.
defaultRevealedbooleanStarts revealed. Default `false`.
revealLabelstringAccessible names of the two buttons. Default `Show value`.
hideLabelstringAccessible name of the hide button. Default "Hide value".
copyLabelstringAccessible name of the copy button. Default "Copy value".
trailingReactNodeExtra buttons or text after the built-in ones.
classNamestringClasses merged onto the root element, after ikada's own.
styleCSSProperties | ((state: InputState) => CSSProperties)Style applied to the element, or a function that returns a style object based on the component's state.
renderReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, InputState>Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render.
invalidbooleanMarks the field invalid: danger ring and aria-invalid. Prefer the Field error.
monobooleanMonospace face for ids, keys and hashes.

Also takes every prop of Omit<InputProps, "type">.

Source: src/components/sensitive-input.tsx