Text Input
Text inputs enable the user to interact with and input content and data.
#
Importimport { TextInput } from '@volue/wave-react';
#
Examples#
Basic#
ControlledIt is most common to set up TextInput
as a controlled component, meaning that React state drives its value. To achieve this you must provide value
and onChange
properties.
#
With Form FieldTextInput
should be clearly labeled so it's obvious to users what they should enter. Optionally, you may want to connect helper text and/or validation feedback message to the input element.
Thus it is recommended to wrap inputs with Form Field to create a consistent set of form fields that are accessible to screen reader users.
#
PlaceholderPlaceholder text provides examples of what to enter.
Placeholder text disappears after the user begins entering data into the input and should not contain crucial information. Do not use placeholder text as a replacement for labels or descriptions.
#
Disabled inputPass isDisabled
prop to the accompanying FormField
and it will cascade down to the input.
You can also pass isDisabled
prop directly to TextInput
.
#
With leading/trailing visualsIn some scenarios, you might need to add a visual positioned on the edge inside the input.
This includes icons for decoration and help distinguishing between inputs, as well as special form of help text that works best inline.
leadingVisual
and trailingVisual
props help with this use case.
Use leadingVisual
for things like currency symbols, country codes, etc.:
Use trailingVisual
for things like units of measure:
By using <Button>
as trailingVisual
, you can create a password input with a show/hide password functionality.
#
SizesWave provides two TextInput
sizes ‐ medium
and small
, with the medium
size used by default. All sizes are aligned with sizes of other related components like Button or Select.
#
Size inheritanceTextInput
automatically inherits size, when placed inside a FormField component.
#
ResponsiveTextInput
supports responsive syntax for its size
property, which means you can change its size based on the viewport.
#
Multi-sizingWave provides applySizes
utility, which lets you specify size "scopes" within your app.
All inputs within a scope will share the same size unless overwritten on a per-control basis.
#
Input groupsVisually grouping closely related fields such as first and last name, or city and zip code can help users make sense of the information they must fill in. You can use layout component such as Auto Grid to arrange fields into groups, or to vary field layouts across different screen sizes.
Fields that are not directly related to each other should not be visually grouped together as this can make it easier to overlook certain fields.
#
API ReferenceIn addition to the props below, you can pass all React.InputHTMLAttributes
.
Prop | Type | Default |
---|---|---|
css | StitchesCss | No default value |
inputCss | StitchesCss | No default value |
type | enum | "text" |
isDisabled | boolean | No default value |
isReadOnly | boolean | No default value |
isRequired | boolean | No default value |
validationStatus | enum | No default value |
leadingVisual | React.ReactNode | No default value |
trailingVisual | React.ReactNode | No default value |
size | enum | No default value |