Back to Shark UI

Password Input

docs/components/password-input

latest9.1 KB
Original Source

Sections

Components

Utilities

Forms

Hooks

Password Input

Copy Markdown

A field for entering secure text.

DocsAPI

PreviewCode

Installation#

CLIManual

pnpmbunnpmyarn

pnpm dlx shadcn@latest add @shark/password-input

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.

PreviewCode

Character count: 0

States#

Disabled#

Use the disabled prop to disable the password input.

PreviewCode

Password

The field is currently disabled.

Invalid#

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

PreviewCode

Password

Please enter a valid password.

Sizes#

Use the size prop to change the input height.

Small#

PreviewCode

Medium#

PreviewCode

Large#

PreviewCode

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

PreviewCode

Current password

For signing in to an existing account.

New password

For creating or resetting a password.

Controlled Visibility#

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

PreviewCode

Auto Hide#

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

PreviewCode

Custom Indicator#

PreviewCode

With Field#

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

PreviewCode

Password

Must be at least 8 characters.

API Reference#

PasswordInput#

Root component. Manages visibility and input state.

PropTypeDefault
size`"sm""md"
autoComplete`"current-password""new-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"
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.

[

Previous page

Pagination ](/docs/components/pagination)[

Next page

Popover ](/docs/components/popover)

On This Page

InstallationAnatomyUsageControlledStatesDisabledInvalidSizesSmallMediumLargeExamplesAutocompleteControlled VisibilityAuto HideCustom IndicatorWith FieldAPI ReferencePasswordInputPasswordInputGroupPasswordInputInputPasswordInputTriggerPasswordInputIndicator