HextaUI

Input group: Password

<InputGroupPasswordToggle /> switches a type="password" field to text and back. The caret and selection stay where they were, a mouse click keeps focus in the field, and the password is hidden again when the form submits. Control it with revealed.

import { IconLock } from "@tabler/icons-react"

import {
  InputGroup,
  InputGroupAddon,
  InputGroupInput,
  InputGroupPasswordToggle,
} from "@/components/ui/input-group"

export function InputGroupPassword() {
  return (
    <InputGroup className="max-w-sm">
      <InputGroupInput
        type="password"
        defaultValue="correct horse battery staple"
        autoComplete="current-password"
        aria-label="Password"
      />
      <InputGroupAddon>
        <IconLock />
      </InputGroupAddon>
      <InputGroupAddon align="inline-end">
        <InputGroupPasswordToggle />
      </InputGroupAddon>
    </InputGroup>
  )
}

This adds the example as components/examples/input-group/password.tsx, together with the Input group component and the HextaUI theme tokens it needs.

pnpm dlx shadcn@latest add https://hextaui.com/r/input-group-password.json

To add only the component, follow the Input group installation.

Props in this example

The Input group props this example sets, from the API reference.

PropTypeDefault
align
"inline-start" | "inline-end" | "block-start" | "block-end""inline-start"

Every prop is in the Input group API reference.

See them all, with keyboard support and accessibility notes, on the Input group page.