TextInput

TextInput is used to set a value that is a single line of text.

Page navigation navigation

Use a TextInput to allow users to input short free-form text. It may also be used as a number input when type="number" is passed to the component.

React examples

Default

Required

Custom size

Adjust input size based on context; use smaller sizes in compact spaces, larger sizes in open spaces or feels out of proportion with adjacent large elements.

Monospace value

Use a monospace font for code-related inputs, like configuration tokens.

In a loading state

When loading, the spinner replaces a visual without shifting layout. Control which side displays the loading indicator as needed.

The TextInput component has internal logic to decide which visual to replace, but it can be overridden and explicitly set to show at the start or end of the input.

Default spinner position
Loading
Loading
Loading
Loading
Overridden spinner position
Loading
Loading

With a caption

This is a caption

With a validation message

Something went wrong

With a leading visual

Leading and trailing visuals, typically icons, clarify input purpose. For context, prefer icons but use text (e.g., “$” or “%”) if helpful.

Avoid overwhelming the TextInput by using both a leading and trailing visual. If you're trying to provide more context about the input, consider using text in the input caption.

With a trailing visual

With a trailing action

Use a trailing action button (e.g., clear button) without a label when possible. Avoid using it alongside a trailing visual.

More code examples

See the TextInput Storybook stories

Props

Loading data for text_input...