Formatted Text Inputs

Text inputs with modifiers that allow the ability to input data in a structured format.

Import

Copy Link

Loading preview
Open in Storybook

Currency Input

Loading preview
Open in Storybook

Date

Loading preview
Open in Storybook

Show Placeholder

Loading preview
Open in Storybook

Hide Placeholder

Loading preview
Open in Storybook

Show Specific Date Fields

Loading preview
Open in Storybook

Localized Date Field

Loading preview
Open in Storybook

Form Value Returned

Loading preview
Open in Storybook

Prefix Input

Loading preview
Open in Storybook

Suffix Input

Loading preview
Open in Storybook

Password Input

Loading preview
Open in Storybook

Phone Input

Single Country

Loading preview
Open in Storybook

Single Country (Only Flag)

Loading preview
Open in Storybook

Single Country (Only Calling Code)

Loading preview
Open in Storybook

Single Country Alternate Country

Loading preview
Open in Storybook

Multiple Country

Loading preview
Open in Storybook

Props

Formatted Text Input Props

Formatted Text Input Props

NameDescriptionDefault
onClick

Callback function to handle clicks events on the copy button.

MouseEventHandler<Element>
-
disabled

@deprecated use aria-disabled instead.

The disabled prop removes the element from the Accessibility Tree and prevents it from receiving focus. This is not recommended.

All DLS components are designed to use the aria-disabled property instead, which will style the component to be disabled, but still allow keyboard focus and screen reader interactivity.

boolean
-
aria-disabled

If true, styles component as disabled and prevents interactivity. Screen reader reads as "dimmed" or "disabled".

Booleanish
-
label

Text that's used as the visual and accessible label for the component. If not provided, hide the component's built-in label.

string
-
autoComplete

Must be defined when the form control collects user personal data. Attribute value must match the tokens defined in input purposes section

string
-
name

The name attribute of the input field, will default to the id provided

string
-
required

Flag to allow for default validation message to show

boolean
-
value

The value of the input field (controlled)

string | number | readonly string[]
-
onChange

The onChange event handler to attach to the input field (controlled)

ChangeEventHandler<HTMLInputElement>
-
id*

The ID for the input field, necessary for accessibility and labeling.

string
-
aria-describedby

The id of the container of the text describing the input, intended for custom hint text

string
-
aria-labelledby

The id of a label, which provides an accessible name for the component Identifies the element (or elements) that labels the current element. @see aria-describedby.

string
-
onError

Callback function triggered when the copy operation fails.

(() => void)
-
inputSlot

@ignore

undefined
-
isVisuallyDisabled

@ignore

undefined
-
statusMessageId

@ignore

undefined
-
status

Default, error, or success state. Will use the value provided by the context when wrapped in a FieldControl component.

FieldControlStatus
-
statusMessage

The status message to be displayed if status is 'success' or 'error'.

string
-
containerProps

Props to be spread onto the parent div container

Omit<DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">
-
hint

Hint text to assist the user, displayed above the input.

string
-
isHintVisuallyHidden

If true, visually hides the hint text (it will still be accessible to screen readers)

boolean
-
timeout

Timeout duration in milliseconds before ressetting the status to default.

number
-
onSuccess

Callback function triggered when the copy operation is successful.

(() => void)
-
onTimeout

Callback function triggered when the timeout elapses.

(() => void)
-
copyButtonProps

Other props to be spread onto the copy button.

Omit<IconButtonProps, "onClick" | "disabled" | "aria-disabled" | "screenReaderLabel">
-
labelOverrides

Overrides for labels that have been defaulted in the component.

CopyLinkInputLabelOverrides
-

Formatted Text Input Props

NameDescriptionDefault
id*

The ID for the input field, necessary for accessibility and labeling.

string
-
value

Value to be shown in the currency input. The value will be reformatted to the proper locale string based on the props supplied. e.g. if locale is "en-US" and currency is "USD" then "3" -> "3.00"; "2143.22" -> "2,143.22"

string | number
-
onChange

The onChange event handler (controlled).

ChangeEventHandler<HTMLInputElement>
-
onBlur

The onBlur event handler (controlled). Should be used to get the normalized (non-localized) value as a number. First argument to function is event object. Second argument to function is object with the following keys: isInvalid to determine if value could not be formatted. 'normalizedValue' that gives the value in normalized (non-localized) format e.g. "10,000.99" -> "10000.99"; "10.000,99" -> "10000.99" 'formattedValue' that gives a formatted value in localized format e.g. "10,000.99"

((event: FocusEvent<HTMLInputElement, Element>, params: CurrencyInputOnBlurParams) => void)
-
disabled

@deprecated use aria-disabled instead.

The disabled prop removes the element from the Accessibility Tree and prevents it from receiving focus. This is not recommended.

All DLS components are designed to use the aria-disabled property instead, which will style the component to be disabled, but still allow keyboard focus and screen reader interactivity.

boolean
-
aria-disabled

If true, styles component as disabled and prevents interactivity. Screen reader reads as "dimmed" or "disabled".

Booleanish
-
label

Text that's used as the visual and accessible label for the component. If not provided, hide the component's built-in label.

string
-
autoComplete

Must be defined when the form control collects user personal data. Attribute value must match the tokens defined in input purposes section

string
-
name

The name attribute of the input field, will default to the id provided

string
-
required

Flag to allow for default validation message to show

boolean
-
defaultValue

Default value to be shown in the field. Will be reformatted to the proper locale string. e.g. "3" -> "3.00"; "2143.22" -> "2,143.22"

string | number
-
aria-describedby

The id of the container of the text describing the input, intended for custom hint text

string
-
aria-labelledby

The id of a label, which provides an accessible name for the component Identifies the element (or elements) that labels the current element. @see aria-describedby.

string
-
inputSlot

@ignore

undefined
-
isVisuallyDisabled

@ignore

undefined
-
statusMessageId

@ignore

undefined
-
status

Default, error, or success state. Will use the value provided by the context when wrapped in a FieldControl component.

FieldControlStatus
-
statusMessage

The status message to be displayed if status is 'success' or 'error'.

string
-
containerRef

A ref to the container element

RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void)
-
containerProps

Props to be spread onto the parent div container

Omit<DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">
-
resetValue

If passed, the input value will be reset to this number when the input is cleared during the onBlur event. The value will be reformatted to the proper locale string based on the props supplied. e.g. if locale is "en-US" and currency is "USD" then "3" -> "3.00"; "2143.22" -> "2,143.22"

string | number
-
currency

ISO 4217 currency code

string
-
locale

BCP 47 language tag

string
-
showFractions

If false will hide the fractional number e.g. "300.00" -> "300"

boolean
-
shouldUseCurrencySymbol

If true will localize currency code (if known) to show symbol e.g. $/£/€

boolean
-
hint

Hint text to use inbuilt hint instead of a custom label

string
-
isHintVisuallyHidden

If true, visually hides the hint text (it will still be accessible to screen readers)

boolean
-

Formatted Text Input Props

NameDescriptionDefault
label

Text that's used as the visual and accessible label for the component. If not provided, hide the component's built-in label. The visible label for the DateInput component.

string
-
aria-labelledby

The id of a label, which provides an accessible name for the component

string
-
id*

The ID for the input field, necessary for accessibility and labeling.

string
-
name

The name used for form submission.

string
-
hint

Hint text to assist the user, displayed below the input.

string
-
isHintVisuallyHidden

If true, visually hides the hint text (it will still be accessible to screen readers)

boolean
-
value

Controlled value for the date input in ISO format ('YYYY-MM-DD') or Date object.

string
-
defaultValue

Default value for uncontrolled usage in ISO format ('YYYY-MM-DD') or Date object.

string
-
onChange

Callback fired when the date changes. @param event the event associated with the individual input field that triggered the change. @param date the date in ISO format ('YYYY-MM-DD').

((event: ChangeEvent<HTMLInputElement>, date: string) => void)
-
onBlur

Callback fired when the date input loses focus. Only gets called if the focus is not moving to another input field within the DateInput component. @param event the event associated with the individual input field that triggered the blur.

((event: FocusEvent<HTMLInputElement, Element>) => void)
-
lang

BCP 47 language tag to format the date input fields according to different cultural norms.

string
-
showPlaceholder

Whether to show placeholders in the input fields

boolean
-
className

Additional CSS class names to apply to the DateInput container.

string
-
fieldsToShow

Specifies which date fields to show and in what order.

("day" | "month" | "year")[]
-
aria-describedby

ID of element providing additional description of the date input

string
-
autocompleteSettings

AutoComplete settings for each of the input field parts

DateInputAutocompleteSettings
-
required

If true, indicates that the consumer must specify a value for the input before the owning form can be submitted.

boolean
-
children

@ignore For DLS Internal use only. The children to position in the input wrapper.

ReactNode
-
labelOverrides

Overrides for labels that have been defaulted in the component.

DateInputLabelOverrides
-
disabled

@deprecated use aria-disabled instead.

The disabled prop removes the element from the Accessibility Tree and prevents it from receiving focus. This is not recommended.

All DLS components are designed to use the aria-disabled property instead, which will style the component to be disabled, but still allow keyboard focus and screen reader interactivity.

boolean
-
aria-disabled

If true, styles component as disabled and prevents interactivity. Screen reader reads as "dimmed" or "disabled".

Booleanish
-
status

Default, error, or success state. Will use the value provided by the context when wrapped in a FieldControl component.

FieldControlStatus
-
statusMessage

The status message to be displayed if status is 'success' or 'error'.

string
-
reactlytics
ReactlyticsProp
-

Formatted Text Input Props

NameDescriptionDefault
onBlur

Handler for focus loss events from any focusable HTML element within the component.

((event: FocusEvent<HTMLElement, Element>) => void)
-
disabled

@deprecated use aria-disabled instead.

The disabled prop removes the element from the Accessibility Tree and prevents it from receiving focus. This is not recommended.

All DLS components are designed to use the aria-disabled property instead, which will style the component to be disabled, but still allow keyboard focus and screen reader interactivity.

boolean
-
aria-disabled

If true, styles component as disabled and prevents interactivity. Screen reader reads as "dimmed" or "disabled".

Booleanish
-
label

Text that's used as the visual and accessible label for the component. If not provided, hide the component's built-in label. The visible label for the PasswordInput component.

string
-
autoComplete

Must be defined when the form control collects user personal data. Attribute value must match the tokens defined in input purposes section

string
-
name

The name attribute of the input field, will default to the id provided

string
-
required

Flag to allow for default validation message to show

boolean
-
value

The value of the input field (controlled)

string | number | readonly string[]
-
onChange

The onChange event handler to attach to the input field (controlled)

ChangeEventHandler<HTMLInputElement>
-
defaultValue

The default value of the input field (uncontrolled)

string | number | readonly string[]
-
id*

The ID for the input field, necessary for accessibility and labeling.

string
-
aria-describedby

The id of the container of the text describing the input, intended for custom hint text

string
-
aria-labelledby

The id of a label, which provides an accessible name for the component Identifies the element (or elements) that labels the current element. @see aria-describedby.

string
-
inputSlot

@ignore

undefined
-
isVisuallyDisabled

@ignore

undefined
-
statusMessageId

@ignore

undefined
-
childrenPosition

Positions the slot (children) to the left or right of the other content within the container

"start" | "end"
-
status

Default, error, or success state. Will use the value provided by the context when wrapped in a FieldControl component.

FieldControlStatus
-
statusMessage

The status message to be displayed if status is 'success' or 'error'.

string
-
containerRef

A ref to the container element

RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void)
-
childrenContainerProps

Props to be spread onto the span containing the children

Omit<DetailedHTMLProps<HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref">
-
containerProps

Props to be spread onto the parent div container

Omit<DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">
-
hint

Hint text to assist the user, displayed above the input.

string
-
isHintVisuallyHidden

If true, visually hides the hint text (it will still be accessible to screen readers)

boolean
-
defaultShouldShowPassword

Shows the password by default.

boolean
-
shouldShowPassword

Controlled visibility of the password

boolean
-
onShowPasswordChange

Handler for changes in password visibility.

((isVisible: boolean) => void)
-
labelOverrides

Overrides for labels that have been defaulted in the component.

PasswordInputLabelOverrides
-

Formatted Text Input Props

NameDescriptionDefault
value

Value to be shown in the PhoneInput (controlled). The value will be reformatted when focus is not on the PhoneInput. e.g. if phoneFormat is "### ### ####" and value is "1234567890" then it will be displayed as "123 456 7890".

string | number
-
onChange

The onChange event handler called when the input is changed.

((event: ChangeEvent<HTMLInputElement>, selectedOption?: SelectOption) => void)
-
onBlur

The onBlur event handler called when the input is blurred.

((event: FocusEvent<HTMLInputElement, Element>, selectedOption?: SelectOption) => void)
-
onFocus

The onFocus event handler called when the input is focused.

((event: FocusEvent<HTMLInputElement, Element>) => void)
-
disabled

@deprecated use aria-disabled instead.

The disabled prop removes the element from the Accessibility Tree and prevents it from receiving focus. This is not recommended.

All DLS components are designed to use the aria-disabled property instead, which will style the component to be disabled, but still allow keyboard focus and screen reader interactivity.

boolean
-
aria-disabled

If true, styles component as disabled and prevents interactivity. Screen reader reads as "dimmed" or "disabled".

Booleanish
-
label

Text that's used as the visual and accessible label for the component. If not provided, hide the component's built-in label.

string
-
name

The name attribute of the input field, will default to the id provided

string
-
required

Flag to allow for default validation message to show

boolean
-
defaultValue

Default value to be shown in the PhoneInput (uncontrolled). The value will be reformatted when focus is not on the PhoneInput. e.g. if phoneFormat is "### ### ####" and defaultValue is "1234567890" then it will be displayed as "123 456 7890".

string | number
-
aria-describedby

The id of the container of the text describing the input, intended for custom hint text

string
-
aria-labelledby

The id of a label, which provides an accessible name for the component Identifies the element (or elements) that labels the current element. @see aria-describedby.

string
-
inputSlot

@ignore

undefined
-
isVisuallyDisabled

@ignore

undefined
-
statusMessageId

@ignore

undefined
-
status

Default, error, or success state. Will use the value provided by the context when wrapped in a FieldControl component.

FieldControlStatus
-
statusMessage

The status message to be displayed if status is 'success' or 'error'.

string
-
containerRef

A ref to the container element

RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void)
-
childrenContainerProps

Props to be spread onto the span containing the children

Omit<DetailedHTMLProps<HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref">
-
containerProps

Props to be spread onto the parent div container

Omit<DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">
-
callingCode

The phone number calling code, e.g. "1", "44" @ignore

string | number
-
phoneFormat

The phone number format, e.g. "### ### ####" @ignore

string
-
locale

BCP 47 language tag e.g. "en-US", "de-DE" @ignore

string
-
country

Screenreader label for country flag @ignore

string
-
showCallingCode

If true, will show calling code on the single country PhoneInput @ignore

boolean
-
showFlag

If true, will show flag (if available) associated with the country in the locale prop @ignore

boolean
-
selectOptions

An array of objects with the following properties: callingCode: The phone number calling code, e.g. "1", "44". phoneFormat: The phone number format, e.g. "### ### ####". locale: BCP 47 language tag e.g. "en-US", "de-DE". country: The name of the country to be displayed in the select dropdown. @ignore

SelectOption[]
-
selectedLocale

BCP 47 language tag e.g. "en-US", "de-DE" of the selected option (controlled) @ignore

string
-
defaultSelectedLocale

BCP 47 language tag e.g. "en-US", "de-DE" of the default selected option (uncontrolled) @ignore

string
-
selectId

The id for the country

-
countrySelectProps

Props to be spread onto the multi-country select. @ignore

Omit<Omit<DetailedHTMLProps<SelectHTMLAttributes<HTMLSelectElement>, HTMLSelectElement>, "ref"> & { ...; }, "id" | ... 5 more ... | "onClick">
-
inputId*

The id for the input field

string
-
hint

Hint text for input

string
-
isHintVisuallyHidden

If true, visually hides the hint text (it will still be accessible to screen readers)

boolean
-
onSelectChange

The onChange event handler called when the multi-country select is changed.

((event: ChangeEvent<HTMLSelectElement>, selectedOption?: SelectOption) => void)
-
onSelectBlur

The onBlur event handler called when the multi-country select is blurred.

((event: FocusEvent<HTMLSelectElement, Element>, selectedOption?: SelectOption) => void)
-
labelOverrides

Overrides for labels that have been defaulted in the component.

PhoneInputLabelOverrides
-
reactlytics
ReactlyticsProp
-

Formatted Text Input Props

NameDescriptionDefault
disabled

@deprecated use aria-disabled instead.

The disabled prop removes the element from the Accessibility Tree and prevents it from receiving focus. This is not recommended.

All DLS components are designed to use the aria-disabled property instead, which will style the component to be disabled, but still allow keyboard focus and screen reader interactivity.

boolean
-
aria-disabled

If true, styles component as disabled and prevents interactivity. Screen reader reads as "dimmed" or "disabled".

Booleanish
-
label

Text that's used as the visual and accessible label for the component. If not provided, hide the component's built-in label.

string
-
autoComplete

Must be defined when the form control collects user personal data. Attribute value must match the tokens defined in input purposes section

string
-
name

The name attribute of the input field, will default to the id provided

string
-
required

Flag to allow for default validation message to show

boolean
-
type

The type of the input component, defaults to 'text'

HTMLInputTypeAttribute
-
value

The value of the input field (controlled)

string | number | readonly string[]
-
onChange

The onChange event handler to attach to the input field (controlled)

ChangeEventHandler<HTMLInputElement>
-
defaultValue

The default value of the input field (uncontrolled)

string | number | readonly string[]
-
id*

The id of the input component, used to associate the input with the built-in accessible label and hint

string
-
aria-describedby

The id of the container of the text describing the input, intended for custom hint text

string
-
aria-labelledby

The id of a label, which provides an accessible name for the component Identifies the element (or elements) that labels the current element. @see aria-describedby.

string
-
inputSlot

@ignore

undefined
-
isVisuallyDisabled

@ignore

undefined
-
statusMessageId

@ignore

undefined
-
childrenPosition

Positions the slot (children) to the left or right of the other content within the container

"start" | "end"
-
status

Default, error, or success state. Will use the value provided by the context when wrapped in a FieldControl component.

FieldControlStatus
-
statusMessage

The status message to be displayed if status is 'success' or 'error'.

string
-
containerRef

A ref to the container element

RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void)
-
containerProps

Props to be spread onto the parent div container

Omit<DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">
-
hint

Hint text to use inbuilt hint instead of a custom label

string
-
isHintVisuallyHidden

If true, visually hides the hint text (it will still be accessible to screen readers)

boolean
-
tooltip

The slot for the tooltip

ReactElement<({ id, placement: placementProp, disableHover, isOpen: openProp, defaultIsOpen, onIsOpenChange, children, shouldCreatePortal, }: TooltipProps) => Element, string | JSXElementConstructor<any>>
-
reactlytics
ReactlyticsProp
-

Questions?

Connect with the DLS Team on Slack or by email.

Resources

Check out additional resources.