structyl

Password Toggle Field API

View component

The full prop reference for the Password Toggle Field component. A password input with a show / hide toggle.

Import

tsx
import { PasswordToggleField } from '@structyl/styled';

Props

Root

Root container that manages visibility state for the password field

PropTypeDefault
asChild#boolean

Replace the root element with the first child element, merging props

visible#boolean

Controlled visibility state of the password field (true=text visible, false=password hidden)

defaultVisible#boolean

Default visibility state when uncontrolled

false
onVisibleChange#(visible: boolean) => void

Callback fired when visibility state changes

className#string

CSS class names (styled version adds 'relative' by default)

...rest#HTMLDivProps

All standard div HTML attributes (id, data-*, role, aria-*, etc.)

Input

Input element that toggles between password and text type based on visibility state

PropTypeDefault
className#string

CSS class names (styled version has pre-applied styling for input appearance, focus, and disabled states)

disabled#boolean

Disables the input field

placeholder#string

Placeholder text to show when input is empty

value#string

Controlled value of the password field

defaultValue#string

Default value when uncontrolled

onChange#(e: React.ChangeEvent<HTMLInputElement>) => void

Callback fired when the input value changes

...rest#HTMLInputProps

All standard input HTML attributes (id, aria-*, data-*, etc.); autoComplete defaults to 'current-password' in primitives

Toggle

Button that toggles the password visibility state; primitives version automatically renders Icon child in styled version

PropTypeDefault
className#string

CSS class names (styled version has pre-applied styling for positioning, hover, and focus states)

onClick#(e: React.MouseEvent<HTMLButtonElement>) => void

Callback fired when button is clicked (composed with internal toggle handler)

...rest#HTMLButtonProps

All standard button HTML attributes; primitives version sets type='button', aria-pressed to visibility state, aria-label to 'Show password'/'Hide password', and data-state to 'visible'/'hidden'

Icon

Conditional icon renderer (primitives only; styled Root/Input/Toggle automatically use Eye/EyeOff icons)

PropTypeDefault
visible#React.ReactNode

Icon/element to render when password is visible (text shown)

hidden#React.ReactNode

Icon/element to render when password is hidden (dots shown)

Source code

If you didn't find what you need here, read the component implementation .

structyl — Accessible React Component Library