Skip to content

Text Input

The TextInput component handles single-line user input, with options for a label, caption, prefix/suffix affixes, validation states, and an info tooltip.

Variations

Disabled

Read only

Optional

By default a labelled input shows a required * marker. Pass optional to remove it and mark the field as optional.

Theme

The TextInput component accepts a theme prop, which defines the visual state of the input: success, warning, or danger.

When an error occurs, pass the message to the error prop — this automatically applies the danger theme. For warnings, pass the warning prop, which applies the warning theme.

Size

The TextInput component accepts a size prop, which defines the overall size of the input field. Available options are md (medium, default) and sm (small).

Prefix & suffix

The TextInput component supports prefix and suffix props, which allow adding content before or after the input field.

With tooltip

tooltipContent sets the content of the label’s info tooltip. tooltipProps passes additional props to the tooltip.

Orientation

The TextInput component accepts an optional orientation prop, which defines the layout direction of the input and its label. Available options are horizontal and vertical (default).

Installation

import { TextInput } from "@harnessio/ui/components";
<TextInput
label="Success Input"
id="someinput"
value="input with value"
placeholder="Enter the value"
theme="success"
/>;