Blode UI
GitHub

Password Input

A password input with a visibility toggle button.

Loading
Loading...
import { Field, FieldDescription, FieldLabel } from "@/components/ui/field";
import { PasswordInput } from "@/components/ui/password-input";
 
export function PasswordInputDemo() {
  return (
    <Field>
      <FieldLabel htmlFor="password-input-demo">Password</FieldLabel>
      <PasswordInput
        autoComplete="current-password"
        id="password-input-demo"
        placeholder="Enter your password"
      />
      <FieldDescription>Click the eye icon to reveal your password.</FieldDescription>
    </Field>
  );
}

Installation

npx shadcn@latest add "https://ui.blode.co/r/styles/default/password-input"

Usage

import { PasswordInput } from "@/components/ui/password-input";
<PasswordInput placeholder="Enter your password" />

Props

PropTypeDefaultDescription
showPasswordboolean-Controlled visibility state.
defaultShowPasswordbooleanfalseInitial visibility state (uncontrolled).
onShowPasswordChange(showPassword: boolean) => void-Callback when visibility is toggled.
classNamestring-Class name applied to the input.
hasErrorbooleanfalseShows error state with a destructive border.
clearablebooleanfalseEnables a clear button when value is present.
onClear() => void-Callback fired when the clear button is clicked.
leftAddonReact.ReactNode-Content displayed before the input field.
rightAddonReact.ReactNode-Content displayed after the input field.
disabledbooleanfalseDisables the input and toggle button.

Examples

Default

Loading
Loading...
import { Field, FieldDescription, FieldLabel } from "@/components/ui/field";
import { PasswordInput } from "@/components/ui/password-input";
 
export function PasswordInputDemo() {
  return (
    <Field>
      <FieldLabel htmlFor="password-input-demo">Password</FieldLabel>
      <PasswordInput
        autoComplete="current-password"
        id="password-input-demo"
        placeholder="Enter your password"
      />
      <FieldDescription>Click the eye icon to reveal your password.</FieldDescription>
    </Field>
  );
}