Skip to Content
DocsEnterpriseBlogShowcase

Password Input

Used to collect passwords.

SourceStorybookRecipe

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,
  PasswordStrengthIndicator,
} from "@/components/ui/password-input"
<PasswordInput />
<PasswordStrengthIndicator />

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 PasswordStrengthIndicator 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.