Skip to main content

Text Input

Accepts variable amounts of freeform user input.

Examples

Basic Text Input

The most basic form field around! Available in two sizes.

import { TextInput } from '@curology/ui-components-web/react/TextInput';

<TextInput
required
label="Label"
placeholder="Placeholder"
id="default-input"
size="{sm|md(default)}"
/>

With Helper Text

More context, like an error message, can be provided via the helperText prop.

Helper Text
Helper Text
import { TextInput } from '@curology/ui-components-web/react/TextInput';

<TextInput
...
helperText="Helper Text"
/>

Critical, Warning, Success, and Disabled States

There are four additional states the TextInput can be in, to indicate danger, warning, success or the inability to be controlled.

Some kind of error
Some kind of error
Some kind of warning
Some kind of warning
Some kind of success
Some kind of success
No touching!
No touching!
import { TextInput } from '@curology/ui-components-web/react/TextInput';

<TextInput
...
state="{critical|warning|success}"
disabled
/>

Critical, Warning, Success, and Disabled States with Icons

When an Icon is used at the start of the input, it will be swapped out depending on error state.

Some kind of error
Some kind of error
Some kind of warning
Some kind of warning
Some kind of success
Some kind of success
No touching!
No touching!
import { TextInput } from '@curology/ui-components-web/react/TextInput';

<TextInput
...
iconStart={<EditIcon />}
state="{critical|warning|success}"
disabled
/>

With a Multiline Input

A textarea will be rendered instead of an input if the multiline prop is passed. Additionally, passing a number to rows will increase the height of the input.

import { TextInput } from '@curology/ui-components-web/react/TextInput';

<TextInput
...
multiline
rows="5"
/>

With a Multiline Input and Highlight

Another additional piece of text can be provided via the highlight prop.

Highlight text.
Highlight text.
Highlight text.
Highlight text.
import { TextInput } from '@curology/ui-components-web/react/TextInput';

<TextInput
...
multiline
highlight="Highlight text."
/>

With Icons

Optional leading or trailing icons can be provided.

import { TextInput } from '@curology/ui-components-web/react/TextInput';

<TextInput
...
iconStart={<PlaceholderIcon />}
iconEnd={<PlaceholderIcon />}
/>

Controlled Text Input

Like all form inputs, a TextInput can either be uncontrolled, or controlled (by providing a value and onChange listener).

import { TextInput } from '@curology/ui-components-web/react/TextInput';

<TextInput
value={someValue}
onChange={(evt, value) => ...}
/>

Props

TextInputProps

NameTypeDefault ValueRequiredDescription
All attributes of a <input />
fieldClassNamestringNoA className to apply to the field.
fieldPropsRecord<string, unknown>NoAny props to spread onto the field container.
helperTextReactNodeNoA string or component to display as helper text beneath the input
highlightReactNodeNoHighlighted helper text to display at the bottom of the multiline text input
highlightClassNamestringNoA className to apply to the highlight.
iconEndComponentClass<any, any> | FunctionComponent<any> | ReactElement<any, string | JSXElementConstructor<any>> | ForwardRefExoticComponent<any>NoAn icon to render at the end of the input.
iconStartComponentClass<any, any> | FunctionComponent<any> | ReactElement<any, string | JSXElementConstructor<any>> | ForwardRefExoticComponent<any>NoAn icon to render at the front of the input.
labelReactNodeNoA string or component to display as a label above the input
multilinefalse | truefalseNoShould a textarea be used instead of an input?
onChangeFormControlChangeEventHandlerNoEmit a new value when the input's selected value changes.
requiredfalse | truefalseNoIs the field required?
resizefalse | truefalseNoCan the textarea be resized?
rowsstring | numberNoHow many rows call should the multiline input be?
size"md" | "sm"'md'NoThe size of the field
state"" | "critical" | "warning" | "success"''NoThe state of the field