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} />

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

PropTypeDefaultDescription
label*stringField label.
styleCSSPropertiesInline 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.
classNamestringAdditional CSS class names applied to the field root, or to the input wrapper when the input is inside an InputGroup.
roleAriaRoleARIA 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.
onFocus(event: FocusEvent<HTMLInputElement>) => voidCalled when the input gains focus.
onBlur(event: FocusEvent<HTMLInputElement>) => voidCalled when the input loses focus.
onChange*( value: string, event: ChangeEvent<HTMLInputElement> | null, ) => voidCalled with the next string value.
onKeyDown(event: KeyboardEvent<HTMLInputElement>) => voidKeyboard event handler for the input.
statusInputStatusStatus displayed on the field.
data-testidstringTest ID applied to the input element.
isDisabledbooleanfalseWhether the input is disabled.
size"sm" | "md" | "lg"Visual size.
isLoadingbooleanfalseWhether the input is loading.
value*stringControlled input value.
placeholderstringPlaceholder text.
autoCompletestringHTML autocomplete hint for the browser.
descriptionReactNodeSupporting text rendered below the label.
hasAutoFocusbooleanfalseWhether to focus the input on mount.
htmlNamestringHTML name attribute.
isLabelHiddenbooleanfalseWhether to visually hide the label.
isReadOnlybooleanfalseWhether the value is displayed without allowing focus or interaction.
labelIconIconComponentIcon shown before the label.
labelTooltipReactNodeTooltip shown beside the label.
onEnter() => voidCalled when Enter is pressed.
isOptionalboolean
isRequiredboolean