Skip to content
Alea0.1

Forms

SearchField and PasswordField

A search box with a clear button, and a password field with show and hide.

Ant Design: Input.Search, Input.Password

import { SearchField, PasswordField } from '@alea/ui';

Examples

Password

Show and hide the value. Use new-password on sign-up forms.

At least 12 characters.

Props

SearchField props

A search box with a clear button; Escape clears it too.

PropTypeDefaultDescription
descriptionReactNode-Help text under the field.
errorMessageReactNode | ((v: ValidationResult) => ReactNode)-Error text, or a function of the validation result. Shown when invalid.
labelReactNode-The visible label. Use aria-label instead only when the context makes it obvious.
placeholderstring'Search'Placeholder text. Default "Search".
showOptionalboolean-Shows "(optional)" after the label.
size"sm" | "md" | "lg"'md'sm 32 px, md 44 px (default), lg 48 px.

PasswordField props

A password input with a show/hide button.

PropTypeDefaultDescription
descriptionReactNode-Help text under the field.
errorMessageReactNode | ((v: ValidationResult) => ReactNode)-Error text, or a function of the validation result. Shown when invalid.
labelReactNode'Password'The visible label. Use aria-label instead only when the context makes it obvious.
placeholderstring-An example of what to type; never a replacement for the label.
prefixReactNode-Icon or text inside the field, before the value.
showOptionalboolean-Shows "(optional)" after the label.
size"sm" | "md" | "lg"-sm 32 px, md 44 px (default), lg 48 px.

Accessibility

  • The search input has role searchbox; Escape clears it.
  • The show password button says what it will do and is a toggle (aria-pressed).

Keyboard

KeyDoes
EscapeClears the search
EnterSubmits the search (onSubmit)

Do and don't

Do

  • Use new-password as autoComplete on sign-up forms.

Don't

  • Don't block pasting into password fields.
Tested with axe, keyboard and screen reader roles