Text input

A text input components allows users to input short text.

Examples

Basic

Disabled

Truncated at start

Read only

Invalid

Select text using ref

Custom icon



Custom icon and invalid

Props

TextInput

*required
NameTypeDefaultDescription
aria-labelstringAria-label. The text input requires an associated id or aria-label.
classNamestringAdditional classes added to the text input.
customIconReact.ReactNodeCustom icon to render. If the validated prop is also passed, this will render an icon in addition to a validated icon.
expandedPropsTextInputExpandedObjProp to apply expanded styling to the text input and link it to the element it is controlling. This should be used when the input controls a menu and that menu is expandable.
isDisabledbooleanFlag to show if the text input is disabled.
Deprecated: isExpandedbooleanFlag to apply expanded styling. expandedProps should now be used instead.
Deprecated: isLeftTruncatedbooleanUse isStartTruncated instead. Trim text at start
isRequiredbooleanFlag indicating whether the input is required
isStartTruncatedbooleanTrim text at start
onBlur(event?: any) => voidCallback function when text input is blurred (focus leaves)
onChange(event: React.FormEvent<HTMLInputElement>, value: string) => voidA callback for when the text input value changes.
onFocus(event?: any) => voidCallback function when text input is focused
ouiaIdnumber | stringValue to overwrite the randomly generated data-ouia-component-id.
ouiaSafebooleanSet the value of data-ouia-safe. Only set to true when the component is in a static state, i.e. no animations are occurring. At all other times, this value must be false.
placeholderstringPlaceholder of the text input when there is no value
readOnlyVariant'plain' | 'default'Sets the input as readonly and determines the readonly styling.
type| 'text' | 'date' | 'datetime-local' | 'email' | 'month' | 'number' | 'password' | 'search' | 'tel' | 'time' | 'url'Type that the text input accepts.
validated'success' | 'warning' | 'error' | 'default'Value to indicate if the text input is modified to show that validation state. If set to success, text input will be modified to indicate valid state. If set to error, text input will be modified to indicate error state.
valuestring | numberValue of the text input.

TextInputExpandedObj

*required
NameTypeDefaultDescription
ariaControlsrequiredstringId of the element that the text input is controlling expansion of.
isExpandedrequiredbooleanFlag to apply expanded styling.

CSS variables

Expand or collapse columnSelectorVariableValue
.pf-v6-c-form-control--pf-v6-c-form-control--ColumnGap
0.5rem
.pf-v6-c-form-control--pf-v6-c-form-control--Color
(In light theme) #151515
.pf-v6-c-form-control--pf-v6-c-form-control--FontSize
0.875rem
.pf-v6-c-form-control--pf-v6-c-form-control--LineHeight
1.5
.pf-v6-c-form-control--pf-v6-c-form-control--Resize
none
.pf-v6-c-form-control--pf-v6-c-form-control--OutlineOffset
-6px
.pf-v6-c-form-control--pf-v6-c-form-control--BorderRadius
6px
.pf-v6-c-form-control--pf-v6-c-form-control--before--BorderWidth
1px
.pf-v6-c-form-control--pf-v6-c-form-control--before--BorderStyle
solid
.pf-v6-c-form-control--pf-v6-c-form-control--before--BorderColor
(In light theme) #c7c7c7
.pf-v6-c-form-control--pf-v6-c-form-control--before--BorderRadius
6px
.pf-v6-c-form-control--pf-v6-c-form-control--after--BorderWidth
1px
.pf-v6-c-form-control--pf-v6-c-form-control--after--BorderStyle
solid
.pf-v6-c-form-control--pf-v6-c-form-control--after--BorderColor
transparent
.pf-v6-c-form-control--pf-v6-c-form-control--after--BorderRadius
6px
.pf-v6-c-form-control--pf-v6-c-form-control--BackgroundColor
(In light theme) #ffffff
.pf-v6-c-form-control--pf-v6-c-form-control--Width
100%
.pf-v6-c-form-control--pf-v6-c-form-control--inset--base
1rem
.pf-v6-c-form-control--pf-v6-c-form-control--PaddingBlockStart
0.5rem
.pf-v6-c-form-control--pf-v6-c-form-control--PaddingBlockEnd
0.5rem
.pf-v6-c-form-control--pf-v6-c-form-control--PaddingInlineEnd
1rem
.pf-v6-c-form-control--pf-v6-c-form-control--PaddingInlineStart
1rem
.pf-v6-c-form-control--pf-v6-c-form-control--hover--after--BorderWidth
1px
.pf-v6-c-form-control--pf-v6-c-form-control--hover--after--BorderColor
(In light theme) #4394e5
.pf-v6-c-form-control--pf-v6-c-form-control--m-success--hover--after--BorderColor
(In light theme) #204d00
.pf-v6-c-form-control--pf-v6-c-form-control--m-warning--hover--after--BorderColor
(In light theme) #b98412
.pf-v6-c-form-control--pf-v6-c-form-control--m-error--hover--after--BorderColor
(In light theme) #731f00
.pf-v6-c-form-control--pf-v6-c-form-control--m-expanded--after--BorderWidth
2px
.pf-v6-c-form-control--pf-v6-c-form-control--m-expanded--after--BorderColor
(In light theme) #0066cc
.pf-v6-c-form-control--pf-v6-c-form-control--m-placeholder--Color
(In light theme) #4d4d4d
.pf-v6-c-form-control--pf-v6-c-form-control--m-placeholder--child--Color
(In light theme) #151515
.pf-v6-c-form-control--pf-v6-c-form-control--m-disabled--Color
(In light theme) #4d4d4d
.pf-v6-c-form-control--pf-v6-c-form-control--m-disabled--BackgroundColor
(In light theme) #c7c7c7
.pf-v6-c-form-control--pf-v6-c-form-control--m-disabled--after--BorderColor
transparent
.pf-v6-c-form-control--pf-v6-c-form-control--m-readonly--BackgroundColor
(In light theme) #f2f2f2
.pf-v6-c-form-control--pf-v6-c-form-control--m-readonly--BorderColor
(In light theme) #e0e0e0
.pf-v6-c-form-control--pf-v6-c-form-control--m-readonly--hover--after--BorderColor
revert
.pf-v6-c-form-control--pf-v6-c-form-control--m-readonly--m-plain--BackgroundColor
transparent
.pf-v6-c-form-control--pf-v6-c-form-control--m-readonly--m-plain--BorderColor
transparent
.pf-v6-c-form-control--pf-v6-c-form-control--m-readonly--m-plain--inset--base
0
.pf-v6-c-form-control--pf-v6-c-form-control--m-readonly--m-plain--OutlineOffset
0
.pf-v6-c-form-control--pf-v6-c-form-control--m-success--after--BorderWidth
1px
.pf-v6-c-form-control--pf-v6-c-form-control--m-success--after--BorderColor
(In light theme) #3d7317
.pf-v6-c-form-control--pf-v6-c-form-control--m-success--PaddingInlineEnd
calc(0.875rem + 1rem + 0.5rem)
.pf-v6-c-form-control--pf-v6-c-form-control--m-warning--after--BorderWidth
1px
.pf-v6-c-form-control--pf-v6-c-form-control--m-warning--after--BorderColor
(In light theme) #dca614
.pf-v6-c-form-control--pf-v6-c-form-control--m-warning--PaddingInlineEnd
calc(0.875rem + 1rem + 0.5rem)
.pf-v6-c-form-control--pf-v6-c-form-control--m-error--after--BorderWidth
1px
.pf-v6-c-form-control--pf-v6-c-form-control--m-error--after--BorderColor
(In light theme) #b1380b
.pf-v6-c-form-control--pf-v6-c-form-control--m-error--PaddingInlineEnd
calc(0.875rem + 1rem + 0.5rem)
.pf-v6-c-form-control--pf-v6-c-form-control--m-error--icon--width
0.875rem
.pf-v6-c-form-control--pf-v6-c-form-control--m-icon--PaddingInlineEnd
calc(1rem + 0.875rem + calc(1rem / 2))
.pf-v6-c-form-control--pf-v6-c-form-control--m-icon--icon--width
0.875rem
.pf-v6-c-form-control--pf-v6-c-form-control--m-icon--icon--spacer
calc(1rem / 2)
.pf-v6-c-form-control--pf-v6-c-form-control--m-icon--icon--PaddingInlineEnd
calc(1rem + 0.875rem + calc(1rem / 2) + 0.875rem + calc(1rem / 2))
.pf-v6-c-form-control--pf-v6-c-form-control__select--PaddingInlineEnd
1rem
.pf-v6-c-form-control--pf-v6-c-form-control__select--PaddingInlineStart
1rem
.pf-v6-c-form-control--pf-v6-c-form-control__select--m-success--m-status--PaddingInlineEnd
calc((0.875rem * 2) + 1rem + 1rem + 1rem)
.pf-v6-c-form-control--pf-v6-c-form-control__select--m-warning--m-status--PaddingInlineEnd
calc((0.875rem * 2) + 1rem + 1rem + 1rem)
.pf-v6-c-form-control--pf-v6-c-form-control__select--m-error--m-status--PaddingInlineEnd
calc((0.875rem * 2) + 1rem + 1rem + 1rem)
.pf-v6-c-form-control--pf-v6-c-form-control--textarea--Width
100%
.pf-v6-c-form-control--pf-v6-c-form-control--textarea--Height
auto
.pf-v6-c-form-control--pf-v6-c-form-control--textarea--PaddingBlockStart--offset
calc(-1 * -6px)
.pf-v6-c-form-control--pf-v6-c-form-control--textarea--PaddingBlockEnd--offset
calc(-1 * -6px)
.pf-v6-c-form-control--pf-v6-c-form-control--textarea--PaddingInlineEnd--offset
calc(-1 * -6px)
.pf-v6-c-form-control--pf-v6-c-form-control--textarea--PaddingInlineStart--offset
calc(-1 * -6px)
.pf-v6-c-form-control--pf-v6-c-form-control__icon--Color
(In light theme) #1f1f1f
.pf-v6-c-form-control--pf-v6-c-form-control__icon--FontSize
0.875rem
.pf-v6-c-form-control--pf-v6-c-form-control__icon--m-status--Color
(In light theme) #1f1f1f
.pf-v6-c-form-control--pf-v6-c-form-control--m-success__icon--m-status--Color
(In light theme) #3d7317
.pf-v6-c-form-control--pf-v6-c-form-control--m-warning__icon--m-status--Color
(In light theme) #dca614
.pf-v6-c-form-control--pf-v6-c-form-control--m-error__icon--m-status--Color
(In light theme) #b1380b
.pf-v6-c-form-control--pf-v6-c-form-control__utilities--Gap
1rem
.pf-v6-c-form-control--pf-v6-c-form-control__utilities--PaddingBlockStart
0.5rem
.pf-v6-c-form-control--pf-v6-c-form-control__utilities--PaddingInlineEnd
1rem
.pf-v6-c-form-control--pf-v6-c-form-control__toggle-icon--PaddingInlineEnd
1rem
.pf-v6-c-form-control--pf-v6-c-form-control__toggle-icon--PaddingInlineStart
1rem
.pf-v6-c-form-control--pf-v6-c-form-control__toggle-icon--Color
(In light theme) #1f1f1f
.pf-v6-c-form-control--pf-v6-c-form-control--m-disabled__toggle-icon--Color
(In light theme) #a3a3a3
.pf-v6-c-form-control.pf-m-textarea.pf-m-success--pf-v6-c-form-control--m-status--PaddingInlineEnd--offset
calc(0.875rem + 0.5rem)
.pf-v6-c-form-control.pf-m-readonly--pf-v6-c-form-control--BackgroundColor
(In light theme) #f2f2f2
.pf-v6-c-form-control.pf-m-readonly--pf-v6-c-form-control--before--BorderColor
(In light theme) #e0e0e0
.pf-v6-c-form-control.pf-m-readonly:hover--pf-v6-c-form-control--hover--after--BorderColor
revert
.pf-v6-c-form-control.pf-m-readonly:not(.pf-m-success, .pf-m-warning, .pf-m-error)--pf-v6-c-form-control--hover--after--BorderColor
revert
.pf-v6-c-form-control.pf-m-readonly.pf-m-plain--pf-v6-c-form-control--m-readonly--BackgroundColor
transparent
.pf-v6-c-form-control.pf-m-readonly.pf-m-plain--pf-v6-c-form-control--m-readonly--BorderColor
transparent
.pf-v6-c-form-control.pf-m-readonly.pf-m-plain--pf-v6-c-form-control--inset--base
0
.pf-v6-c-form-control.pf-m-readonly.pf-m-plain--pf-v6-c-form-control--before--BorderStyle
none
.pf-v6-c-form-control.pf-m-readonly.pf-m-plain--pf-v6-c-form-control--after--BorderStyle
none
.pf-v6-c-form-control.pf-m-readonly.pf-m-plain--pf-v6-c-form-control--OutlineOffset
0
.pf-v6-c-form-control.pf-m-expanded--pf-v6-c-form-control--after--BorderColor
(In light theme) #0066cc
.pf-v6-c-form-control.pf-m-expanded--pf-v6-c-form-control--after--BorderWidth
2px
.pf-v6-c-form-control.pf-m-disabled--pf-v6-c-form-control--BackgroundColor
(In light theme) #c7c7c7
.pf-v6-c-form-control.pf-m-disabled--pf-v6-c-form-control--Color
(In light theme) #4d4d4d
.pf-v6-c-form-control.pf-m-disabled--pf-v6-c-form-control--m-placeholder--Color
(In light theme) #4d4d4d
.pf-v6-c-form-control.pf-m-disabled--pf-v6-c-form-control__toggle-icon--Color
(In light theme) #a3a3a3
.pf-v6-c-form-control.pf-m-disabled--pf-v6-c-form-control--before--BorderStyle
none
.pf-v6-c-form-control.pf-m-disabled--pf-v6-c-form-control--after--BorderStyle
none
.pf-v6-c-form-control.pf-m-error--pf-v6-c-form-control--PaddingInlineEnd
calc(0.875rem + 1rem + 0.5rem)
.pf-v6-c-form-control.pf-m-error--pf-v6-c-form-control--after--BorderColor
(In light theme) #b1380b
.pf-v6-c-form-control.pf-m-error--pf-v6-c-form-control--hover--after--BorderColor
(In light theme) #731f00
.pf-v6-c-form-control.pf-m-error--pf-v6-c-form-control__icon--m-status--Color
(In light theme) #b1380b
.pf-v6-c-form-control.pf-m-error--pf-v6-c-form-control__select--PaddingInlineEnd
calc((0.875rem * 2) + 1rem + 1rem + 1rem)
.pf-v6-c-form-control.pf-m-error--pf-v6-c-form-control--after--BorderWidth
1px
.pf-v6-c-form-control.pf-m-error.pf-m-icon--pf-v6-c-form-control--PaddingInlineEnd
calc(1rem + 0.875rem + calc(1rem / 2) + 0.875rem + calc(1rem / 2))
.pf-v6-c-form-control.pf-m-success--pf-v6-c-form-control--PaddingInlineEnd
calc(0.875rem + 1rem + 0.5rem)
.pf-v6-c-form-control.pf-m-success--pf-v6-c-form-control--after--BorderColor
(In light theme) #3d7317
.pf-v6-c-form-control.pf-m-success--pf-v6-c-form-control--hover--after--BorderColor
(In light theme) #204d00
.pf-v6-c-form-control.pf-m-success--pf-v6-c-form-control__icon--m-status--Color
(In light theme) #3d7317
.pf-v6-c-form-control.pf-m-success--pf-v6-c-form-control__select--PaddingInlineEnd
calc((0.875rem * 2) + 1rem + 1rem + 1rem)
.pf-v6-c-form-control.pf-m-success--pf-v6-c-form-control--after--BorderWidth
1px
.pf-v6-c-form-control.pf-m-success.pf-m-icon--pf-v6-c-form-control--PaddingInlineEnd
calc(1rem + 0.875rem + calc(1rem / 2) + 0.875rem + calc(1rem / 2))
.pf-v6-c-form-control.pf-m-warning--pf-v6-c-form-control--PaddingInlineEnd
calc(0.875rem + 1rem + 0.5rem)
.pf-v6-c-form-control.pf-m-warning--pf-v6-c-form-control--after--BorderColor
(In light theme) #dca614
.pf-v6-c-form-control.pf-m-warning--pf-v6-c-form-control--hover--after--BorderColor
(In light theme) #b98412
.pf-v6-c-form-control.pf-m-warning--pf-v6-c-form-control__icon--m-status--Color
(In light theme) #dca614
.pf-v6-c-form-control.pf-m-warning--pf-v6-c-form-control__select--PaddingInlineEnd
calc((0.875rem * 2) + 1rem + 1rem + 1rem)
.pf-v6-c-form-control.pf-m-warning--pf-v6-c-form-control--after--BorderWidth
1px
.pf-v6-c-form-control.pf-m-warning.pf-m-icon--pf-v6-c-form-control--PaddingInlineEnd
calc(1rem + 0.875rem + calc(1rem / 2) + 0.875rem + calc(1rem / 2))
.pf-v6-c-form-control:hover--pf-v6-c-form-control--after--BorderColor
(In light theme) #4394e5
.pf-v6-c-form-control:hover--pf-v6-c-form-control--after--BorderWidth
1px
.pf-v6-c-form-control.pf-m-icon--pf-v6-c-form-control--PaddingInlineEnd
calc(1rem + 0.875rem + calc(1rem / 2))
.pf-v6-c-form-control > select--pf-v6-c-form-control--PaddingInlineEnd
1rem
.pf-v6-c-form-control > select--pf-v6-c-form-control--PaddingInlineStart
1rem
.pf-v6-c-form-control.pf-m-placeholder > select--pf-v6-c-form-control--Color
(In light theme) #4d4d4d
.pf-v6-c-form-control.pf-m-resize-vertical--pf-v6-c-form-control--Resize
vertical
.pf-v6-c-form-control.pf-m-resize-horizontal--pf-v6-c-form-control--Resize
horizontal
.pf-v6-c-form-control.pf-m-resize-both--pf-v6-c-form-control--Resize
both
.pf-v6-c-form-control__icon.pf-m-status--pf-v6-c-form-control__icon--Color
(In light theme) #1f1f1f
select ~ .pf-v6-c-form-control__utilities--pf-v6-c-form-control__utilities--PaddingInlineEnd
0