Skip to content

PasswordInput

Password input with a toggle to show or hide the entered value.

function ControlledPasswordInput({
isOptional,
isRequired,
value: initialValue = '',
...args
}: ControlledPasswordInputProps): React.JSX.Element {
const [value, setValue] = useState(initialValue);
const props = {
...args,
onChange: setValue,
value,
};
if (isOptional === true) {
return <PasswordInput {...props} isOptional />;
}
return <PasswordInput {...props} isRequired={isRequired} />;
}
<ControlledPasswordInput {...args} />
function ControlledPasswordInput({
isOptional,
isRequired,
value: initialValue = '',
...args
}: ControlledPasswordInputProps): React.JSX.Element {
const [value, setValue] = useState(initialValue);
const props = {
...args,
onChange: setValue,
value,
};
if (isOptional === true) {
return <PasswordInput {...props} isOptional />;
}
return <PasswordInput {...props} isRequired={isRequired} />;
}
<ControlledPasswordInput {...args} />
function ControlledPasswordInput({
isOptional,
isRequired,
value: initialValue = '',
...args
}: ControlledPasswordInputProps): React.JSX.Element {
const [value, setValue] = useState(initialValue);
const props = {
...args,
onChange: setValue,
value,
};
if (isOptional === true) {
return <PasswordInput {...props} isOptional />;
}
return <PasswordInput {...props} isRequired={isRequired} />;
}
<ControlledPasswordInput {...args} />
function ControlledPasswordInput({
isOptional,
isRequired,
value: initialValue = '',
...args
}: ControlledPasswordInputProps): React.JSX.Element {
const [value, setValue] = useState(initialValue);
const props = {
...args,
onChange: setValue,
value,
};
if (isOptional === true) {
return <PasswordInput {...props} isOptional />;
}
return <PasswordInput {...props} isRequired={isRequired} />;
}
<ControlledPasswordInput {...args} />
function ControlledPasswordInput({
isOptional,
isRequired,
value: initialValue = '',
...args
}: ControlledPasswordInputProps): React.JSX.Element {
const [value, setValue] = useState(initialValue);
const props = {
...args,
onChange: setValue,
value,
};
if (isOptional === true) {
return <PasswordInput {...props} isOptional />;
}
return <PasswordInput {...props} isRequired={isRequired} />;
}
<ControlledPasswordInput {...args} />
function ControlledPasswordInput({
isOptional,
isRequired,
value: initialValue = '',
...args
}: ControlledPasswordInputProps): React.JSX.Element {
const [value, setValue] = useState(initialValue);
const props = {
...args,
onChange: setValue,
value,
};
if (isOptional === true) {
return <PasswordInput {...props} isOptional />;
}
return <PasswordInput {...props} isRequired={isRequired} />;
}
<ControlledPasswordInput {...args} />
Must be at least 8 characters with a number and symbol.
function ControlledPasswordInput({
isOptional,
isRequired,
value: initialValue = '',
...args
}: ControlledPasswordInputProps): React.JSX.Element {
const [value, setValue] = useState(initialValue);
const props = {
...args,
onChange: setValue,
value,
};
if (isOptional === true) {
return <PasswordInput {...props} isOptional />;
}
return <PasswordInput {...props} isRequired={isRequired} />;
}
<ControlledPasswordInput {...args} />
function ControlledPasswordInput({
isOptional,
isRequired,
value: initialValue = '',
...args
}: ControlledPasswordInputProps): React.JSX.Element {
const [value, setValue] = useState(initialValue);
const props = {
...args,
onChange: setValue,
value,
};
if (isOptional === true) {
return <PasswordInput {...props} isOptional />;
}
return <PasswordInput {...props} isRequired={isRequired} />;
}
<div style={{display: 'flex', flexDirection: 'column', gap: 16}}>
<ControlledPasswordInput label="Small" placeholder="Password" size="sm" />
<ControlledPasswordInput
label="Medium"
placeholder="Password"
size="md"
/>
<ControlledPasswordInput label="Large" placeholder="Password" size="lg" />
</div>
function ControlledPasswordInput({
isOptional,
isRequired,
value: initialValue = '',
...args
}: ControlledPasswordInputProps): React.JSX.Element {
const [value, setValue] = useState(initialValue);
const props = {
...args,
onChange: setValue,
value,
};
if (isOptional === true) {
return <PasswordInput {...props} isOptional />;
}
return <PasswordInput {...props} isRequired={isRequired} />;
}
<ControlledPasswordInput {...args} />
function ControlledPasswordInput({
isOptional,
isRequired,
value: initialValue = '',
...args
}: ControlledPasswordInputProps): React.JSX.Element {
const [value, setValue] = useState(initialValue);
const props = {
...args,
onChange: setValue,
value,
};
if (isOptional === true) {
return <PasswordInput {...props} isOptional />;
}
return <PasswordInput {...props} isRequired={isRequired} />;
}
<ControlledPasswordInput {...args} />
function ControlledPasswordInput({
isOptional,
isRequired,
value: initialValue = '',
...args
}: ControlledPasswordInputProps): React.JSX.Element {
const [value, setValue] = useState(initialValue);
const props = {
...args,
onChange: setValue,
value,
};
if (isOptional === true) {
return <PasswordInput {...props} isOptional />;
}
return <PasswordInput {...props} isRequired={isRequired} />;
}
<ControlledPasswordInput {...args} />
function ControlledPasswordInput({
isOptional,
isRequired,
value: initialValue = '',
...args
}: ControlledPasswordInputProps): React.JSX.Element {
const [value, setValue] = useState(initialValue);
const props = {
...args,
onChange: setValue,
value,
};
if (isOptional === true) {
return <PasswordInput {...props} isOptional />;
}
return <PasswordInput {...props} isRequired={isRequired} />;
}
<ControlledPasswordInput {...args} />
function ControlledPasswordInput({
isOptional,
isRequired,
value: initialValue = '',
...args
}: ControlledPasswordInputProps): React.JSX.Element {
const [value, setValue] = useState(initialValue);
const props = {
...args,
onChange: setValue,
value,
};
if (isOptional === true) {
return <PasswordInput {...props} isOptional />;
}
return <PasswordInput {...props} isRequired={isRequired} />;
}
<ControlledPasswordInput {...args} />

Password input with a toggle to show or hide the entered value.

PropTypeDefaultDescription
label*string—Field label.
styleCSSProperties—Inline styles applied to the field root, or to the input wrapper when the input is inside an InputGroup.
refRef<HTMLInputElement>—Ref forwarded to the input element.
classNamestring—Additional CSS class names applied to the field root, or to the input wrapper when the input is inside an InputGroup.
roleAriaRole—ARIA role applied to the input element.
aria-activedescendantAriaAttributes['aria-activedescendant']—Identifies the currently active element in a composite widget controlled by the input.
aria-autocompleteAriaAttributes['aria-autocomplete']—Indicates whether typing displays completion suggestions.
aria-controlsAriaAttributes['aria-controls']—Identifies the element controlled by the input.
aria-requiredboolean—Announces the input as required to assistive technology without showing the Required marker, for fields whose requirement is already obvious. isRequired implies it.
onFocus(event: FocusEvent<HTMLInputElement>) => void—Called when the input gains focus.
onBlur(event: FocusEvent<HTMLInputElement>) => void—Called when the input loses focus.
onChange*( value: string, event: ChangeEvent<HTMLInputElement> | null, ) => void—Called with the next string value.
onKeyDown(event: KeyboardEvent<HTMLInputElement>) => void—Keyboard event handler for the input.
statusInputStatus—Status displayed on the field.
isDisabledbooleanfalseWhether the input is disabled.
size"sm" | "md" | "lg"—Visual size.
isLoadingbooleanfalseWhether the input is loading.
value*string—Controlled input value.
placeholderstring—Placeholder text.
autoCompletestring—HTML autocomplete hint for the browser.
descriptionReactNode—Supporting text rendered below the label.
hasAutoFocusbooleanfalseWhether to focus the input on mount.
htmlNamestring—HTML name attribute.
isLabelHiddenbooleanfalseWhether to visually hide the label.
isReadOnlybooleanfalseWhether the value is displayed without allowing focus or interaction.
labelEndReactNode—Content shown at the end of the label row, such as a link. It renders outside the label, so it does not focus the control or change its accessible name. It stays visible when isLabelHidden is true.
labelIconIconComponent—Icon shown before the label.
labelTooltipReactNode—Tooltip shown beside the label.
onEnter() => void—Called when Enter is pressed.
isOptionalboolean—
isRequiredboolean—
data-testidstring—Test ID applied to the input element.