Skip to content
shadcn.io is not affiliated with official shadcn/ui

Shadcn Password Input for React and Tailwind

A field for entering secure text.

Installation

bunx --bun shadcn@latest add https://kit.dev/r/password-input.json

Anatomy

PasswordInput
└── PasswordInputGroup
    ├── PasswordInputInput
    └── PasswordInputTrigger

Usage

import {
  PasswordInput,
  PasswordInputGroup,
  PasswordInputInput,
  PasswordInputTrigger,
} from "@/components/ui/password-input";
<PasswordInput>
  <PasswordInputGroup>
    <PasswordInputInput placeholder="Enter password" />
    <PasswordInputTrigger />
  </PasswordInputGroup>
</PasswordInput>

Controlled

Use value and onChange on PasswordInputInput to control the password value.

States

Disabled

Use the disabled prop to disable the password input.

Invalid

Use the invalid prop to mark the password input as invalid.

Sizes

Use the size prop to change the input height.

Small

Medium

Large

Examples

Autocomplete

Use the autoComplete prop to hint autofill behavior to the browser.

  • current-password — signing in with an existing password
  • new-password — creating or resetting a password

Controlled Visibility

Use visible and onVisibilityChange to control whether the value is shown.

Auto Hide

Use visible, onVisibilityChange, and a timer to hide the password again after it is revealed.

Custom Indicator

With Field

Combine with Field components, for labeled password fields with helper text.

API Reference

PasswordInput

Root component. Manages visibility and input state.

PropTypeDefault
size"sm" | "md" | "lg""md"
autoComplete"current-password" | "new-password""current-password"
defaultVisiblebooleanfalse
visibleboolean-
disabledboolean-
invalidboolean-
readOnlyboolean-
requiredboolean-
namestring-
ignorePasswordManagersboolean-
onVisibilityChange(details: VisibilityChangeDetails) => void-
classNamestring-
asChildbooleanfalse

PasswordInputGroup

Wraps the input and visibility trigger.

PropTypeDefault
classNamestring-
asChildbooleanfalse

PasswordInputInput

Password field.

PropTypeDefault
size"sm" | "md" | "lg""md"
classNamestring-
asChildbooleanfalse

PasswordInputTrigger

Button that toggles visibility.

PropTypeDefault
classNamestring-

PasswordInputIndicator

Renders different icons based on visibility. Use fallback for the hidden state and pass the visible-state icon as children.

PropTypeDefault
fallbackReact.ReactNode<EyeOffIcon />
childrenReact.ReactNode<EyeIcon />
classNamestring-

For a complete list of props, see the Ark UI documentation.