Axon 911 Frontend DocsAxon 911 Frontend Docs
Axon 911 Frontend Docs
    Loading navigation…
U
User
Switch to light mode
  1. Components
  2. Field
  3. API and Development

Field

API and Development

View SourceOpens in a new tabSubmit IssueOpens in a new tab
Import Field, FieldMaskType, FieldStack, FieldType from @prepared911/ui/field.
Field
PropTypeDefaultNotes
labelLocalizedMessagerequiredVisible label.
typeFieldTypeFieldType.TextText, Email, Url, Tel, Search, Password. InputWithSelect is reserved.
valuestring | null;Controlled value. With a mask it is the formatted text. null is a controlled empty value.
defaultValuestring""Uncontrolled initial value and form-reset target. A mask formats it.
onValueChange(value, details: FieldValueChangeDetails) => void;details.reason is InputChange, FormReset, ImperativeAction or None. A masked Field adds details.raw, and phone adds details.e164 and details.extension.
maskFieldMaskType | (text: string) => string | false;See Masks. Tel, Url and Email default to their mask; false turns that off.
localestringNearest LocaleProvider, then "en-US"BCP 47 locale for the Currency mask.
descriptionLocalizedMessage;Supporting copy below the control. Put the expected mask format here.
error, invalidLocalizedMessage, boolean;Error copy shows when invalid is true.
required, requiredHintboolean, LocalizedMessage;Label marker and form-level explanation.
prefix, suffixLocalizedMessage | DisplayValue;Static text segments inside the control.
leadingIcon, trailingIconReactNode;Decorative icons. Field sets their size (16px) and color (subtle).
actionFieldAction;One tail Button. Not available with Search or Password.
sizeInputSizeInputSize.LargeControl scale.
clearLabelLocalizedMessagerequired for SearchAccessible name of the clear Button.
revealLabel, hideLabelLocalizedMessagerequired for PasswordAccessible names of the reveal Button.
Native input attributes forward to the host, except style, children and onChange. autoComplete and name pass through and are never defaulted: set the purpose token (email, tel, postal-code, username, …) on every field about the user (WCAG 1.3.5). Keyboard and spellcheck: Email, Url and Tel render type="email", "url" and "tel" with spellcheck="false". A built-in mask on a text Field sets the keyboard and turns spellcheck off (table below); a custom mask sets neither. A Password Field always renders spellcheck="false", concealed or revealed, and neither a mask nor a spellCheck you pass changes that. On any other Field, inputMode and spellCheck you pass win.
Masks
FieldMaskTypeDisplaydetails.rawinputMode
Phone(555) 123-4567; +1 (555) 123-4567; other + numbers in groups of three; optional *1234 or #1234 extensionNational digits (5551234567), or all digits after + for non-North-American numberstel
PostalCode12345, 12345-6789Digitsnumeric
CurrencyLocale grouping and decimal separator, at most two fraction digits, no symbolPlain decimal, such as 1234.5decimal
UrlWhitespace removed, case keptThe text as typedurl
EmailWhitespace removed, case keptThe text as typedemail
A custom formatter receives the text as typed and returns the display text. It must give the same output when it formats its own output. details.raw is the text as typed. Phone details.e164 is +15551234567 once the number is complete (ten North American digits, or at least eight digits after +), and an empty string before that. details.extension holds the extension digits. The extension is not part of raw or e164.
FieldAction
The props of Button (children, or icon with label; onClick, intent, loading, disabled), without size, variant, type, className, ref and preventFocusOnPress, which Field sets. The action disables with the field and stays enabled when the field is read-only.
Exports
Field, FieldType, FieldMaskType, and the types FieldProps, FieldMask, FieldMaskDetails, FieldMaskFormatter, FieldAction, FieldAdornmentCopy, FieldValueChangeDetails, FieldValueChangeReason.
Props
NameTypeDefaultDescription
labelLocalizedMessage—Visible label copy.
actionFieldAction——
autoCompleteHTMLInputAutoCompleteAttribute—Autofill purpose token. Set it on every field that collects information about the user: name, email, tel, street-address, postal-code, username, current-password, new-password, one-time-code, or a section and shipping or billing prefix before one. Input turns spellcheck off for identifier purposes. Do not pass off to a field that collects personal data; no design-system control defaults to it except NumberField, which a token replaces.
classNamestring—Classes on the root wrapper.
clearLabelLocalizedMessage | (string & { readonly [LOCALIZED_MESSAGE_BRAND]: true; })—Accessible name for the search clear control when type is {@link FieldType.Search}. Accessible name for the clear control when the field has a value.
defaultValuestring—Initial value when uncontrolled.
descriptionLocalizedMessage—Supporting copy below the control.
errorLocalizedMessage—Error copy when {@link invalid} is true.
hideLabelLocalizedMessage | (string & { readonly [LOCALIZED_MESSAGE_BRAND]: true; })—Accessible name to hide a revealed password when type is {@link FieldType.Password}. Accessible name when the secret is visible.
invalidboolean—When true, the control uses destructive border treatment and exposes error semantics.
leadingIconReactNode—Decorative icon before the input; not interactive.
localestring—BCP 47 locale for the Currency mask. Defaults to the nearest LocaleProvider, then en-US, so server and client render the same text. The shell supplies the agency locale once; pass this only to override it.
maskfalse | FieldMask—Input mask. A {@link FieldMaskType } or a custom formatter. FieldType.Tel, Url and Email default to their matching mask; false turns the default off. value and onValueChange carry the formatted text; details.raw carries the unformatted value.
namestring—Form control name, submitted with the form. Browsers also read it as an autofill hint, so pass a meaningful one.
onValueChange((value: string | null, details: FieldValueChangeDetails) => void)—Value change callback with {@link FieldValueChangeReason}.
placeholderLocalizedMessage—Placeholder when empty.
prefixFieldAdornmentCopy—Static text before the input inside the control row.
refRef<HTMLInputElement>—Ref to the rendered input.
requiredboolean—When true, Label shows the marker and the control is required / aria-required.
requiredHintLocalizedMessage—Form-level explanation of required fields (Decision FLD-1).
revealLabelLocalizedMessage | (string & { readonly [LOCALIZED_MESSAGE_BRAND]: true; })—Accessible name to reveal a password value when type is {@link FieldType.Password}. Accessible name when the secret is hidden.
selectFieldSelectProps—Select inside the control frame, before or after the input.
sizeInputSize—Control scale. Defaults to {@link InputSize.Large}.
suffixFieldAdornmentCopy—Static text after the input inside the control row.
trailingIconReactNode—Decorative icon after the input; not interactive. Sits before the suffix and tail Buttons.
typeFieldType—Field variant. Defaults to {@link FieldType.Text}.
valuestring | null—Controlled value. null is a controlled empty value.
Storybook
Interactive examples and edge cases for this component are in Storybook.
DefaultOpens in a new tab
Previous
Field / Usage
Next
Field / Accessibility
On this page
Field
Masks
FieldAction
Exports
Props
Storybook