Build faster with Premium Chakra UI Components 💎

Learn more
Skip to Content
DocsPlaygroundGuidesBlog
Sponsor

Password Input

Used to collect passwords.

Setup

If you don't already have the snippet, run the following command to add the password-input snippet

chakra snippet add password-input

The snippet includes a closed component composition for the PasswordInput component.

Usage

import {
  PasswordInput,
  PasswordStrengthMeter,
} from "@/components/ui/password-input"
<PasswordInput />
<PasswordStrengthMeter />

Examples

Sizes

Use the size prop to change the size of the password input.

info
The password input sizes are mapped to the Input component sizes.

Controlled

Use the value and onChange props to control the current page.

Hook Form

Here's an example of how to use the PasswordInput component with react-hook-form.

Controlled Visibility

Use the visible and onVisibleChange props to control the visibility of the password input.

Password is hidden

Strength Indicator

Render the PasswordStrengthMeter component to show the strength of the password. Compute the value prop based on the password input value.

Medium

Props

Root

PropDefaultType
defaultVisible false
boolean

The default visibility state of the password input.

visible
boolean

The controlled visibility state of the password input.

onVisibleChange
(visible: boolean) => void

Callback invoked when the visibility state changes.

visibilityIcon
{ on: React.ReactNode; off: React.ReactNode }

Custom icons for the visibility toggle button.

Previous

Pagination

Next

Pin Input