PasswordField

A password field is a specialized text field that allows a user to enter a password.

Anatomy

Composed Components

A PassworField uses the following components.

Usage

Disabled

A password field in a disabled state shows that an input field exists, but is not available in that circumstance. This can be used to maintain layout continuity and communicate that a field may become available later.

ReadOnly

The isReadOnly prop makes the PasswordField's text content immutable. Unlike isDisabled, the password field remains focusable and its content can still be copied. See the MDN docs for more information.

Error

A password field can be displayed in an error state to indicate that the user input is invalid.

Sizes

Password fields can vary in size.

Labeling

If a visible label isn't specified, an aria-label must be provided to the password field for accessibility. If the field is labeled by a separate element, an aria-labelledby prop must be provided using the ID of the labeling element instead.

Description

A password field with a helper message.

Props

placeholder?

The placeholder text when the PasswordField is empty.

size?

The size of the PasswordField.

Defaults to md.
isFluid?

If true, the PasswordField will take all available width.

Defaults to false.
inputRef?

A ref for the HTML input element.

necessityIndicator?

Whether the required state should be shown as an asterisk or a label, which would display (Optional) on all non required field labels.

inputGroupProps?

The props for the InputGroup.

inputProps?

The props for the Input.

embeddedButtonProps?

The props for the EmbeddedButton.

style?

The inline style for the element. A function may be provided to compute the style based on component state.

pattern?

Regex pattern that the value of the input must match to be valid. See MDN.

validationBehavior?

Whether to use native HTML form validation to prevent form submission when the value is missing or invalid, or mark the field as required or invalid via ARIA.

Defaults to 'native'.
isDisabled?

Whether the input is disabled.

isReadOnly?

Whether the input can be selected but not changed by the user.

isRequired?

Whether user input is required on the input before form submission.

isInvalid?

Whether the value is invalid.

validate?

A function that returns an error message if a given value is invalid. Validation errors are displayed to the user when the form is submitted if validationBehavior="native". For realtime validation, use the isInvalid prop instead.

autoFocus?

Whether the element should receive focus on render.

value?

The current value (controlled).

defaultValue?

The default value (uncontrolled).

onChange?

Handler that is called when the value changes.

id?

The element's unique identifier. See MDN.

autoComplete?

Describes the type of autocomplete functionality the input should provide if any. See MDN.

maxLength?

The maximum number of characters supported by the input. See MDN.

minLength?

The minimum number of characters required by the input. See MDN.

inputMode?

Hints at the type of data that might be entered by the user while editing the element or its contents. See MDN.

name?

The name of the input element, used when submitting an HTML form. See MDN.

className?

The CSS className for the element. A function may be provided to compute the class based on component state.

children?

The children of the component. A function may be provided to alter the children based on component state.

Migration Notes

  • Boolean props are now prefixed by is.
  • There is no longer a loading state.
  • icon prop has been renamed to prefix.
  • Button props have been removed. To add a clear button, use the isClearable prop. For a more complex use case, create your own input using InputGroup.
  • wrapperProps no longer exists.
  • validationState has been changed to isInvalid.