Password Toggle Field API
View componentThe full prop reference for the Password Toggle Field component. A password input with a show / hide toggle.
Import
import { PasswordToggleField } from '@structyl/styled';Props
Root
Root container that manages visibility state for the password field
| Prop | Type | Default |
|---|---|---|
| asChild# | booleanReplace the root element with the first child element, merging props | — |
| visible# | booleanControlled visibility state of the password field (true=text visible, false=password hidden) | — |
| defaultVisible# | booleanDefault visibility state when uncontrolled | false |
| onVisibleChange# | (visible: boolean) => voidCallback fired when visibility state changes | — |
| className# | stringCSS class names (styled version adds 'relative' by default) | — |
| ...rest# | HTMLDivPropsAll standard div HTML attributes (id, data-*, role, aria-*, etc.) | — |
Input
Input element that toggles between password and text type based on visibility state
| Prop | Type | Default |
|---|---|---|
| className# | stringCSS class names (styled version has pre-applied styling for input appearance, focus, and disabled states) | — |
| disabled# | booleanDisables the input field | — |
| placeholder# | stringPlaceholder text to show when input is empty | — |
| value# | stringControlled value of the password field | — |
| defaultValue# | stringDefault value when uncontrolled | — |
| onChange# | (e: React.ChangeEvent<HTMLInputElement>) => voidCallback fired when the input value changes | — |
| ...rest# | HTMLInputPropsAll 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
| Prop | Type | Default |
|---|---|---|
| className# | stringCSS class names (styled version has pre-applied styling for positioning, hover, and focus states) | — |
| onClick# | (e: React.MouseEvent<HTMLButtonElement>) => voidCallback fired when button is clicked (composed with internal toggle handler) | — |
| ...rest# | HTMLButtonPropsAll 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)
| Prop | Type | Default |
|---|---|---|
| visible# | React.ReactNodeIcon/element to render when password is visible (text shown) | — |
Source code
If you didn't find what you need here, read the component implementation .