TextField

Designer doc
TextField component for single-line text input.

Example

Basic Usage
View code
Note that placeholder prop also accepts ReactElements, which is normally not supported using traditional HTML attribute. This allows more flexibility in what you put in the placeholder.
View code
Full width
In order to get 100% width, you can specify fullWidth prop to true.
View code
Disabled state
View code
Invalid state
There are two ways specifying TextField as invalid: (1) Through Field or (2) directly passing invalid prop to TextField. If you specify invalid prop to TextField, it takes higher precedence than the one from enclosing Field‘s.
View code
Addons
You can add something on the left and right side of the TextField. There are also some built-ins addons like TextFieldCharCount and TextFieldClear components.
View code

References

Reading: The Evolution of Material Design’s Text Fields. The redesign includes the finding of text field with semi-transparent fill is more distinguishable, easier to find and read, and more understandable.

API

TextField
Prop nameTypeDefaultDescription
asany
Tag or component, but a simple tag (i.e. built-in components, e.g. div, span) is recommended.
autoComplete"on" | "off" | "nope"off
defaultValuestring
@deprecated use initialValue
disabledboolean
fullWidthboolean
width: 100% is too troublesome to handle with custom css because of the nesting
initialValuestring
invalidboolean
leftElementReactNode
leftElementContainerPropsHTMLAttributes<HTMLDivElement> & { ref?: MutableRefObject<HTMLDivElement>; }
onChange(e: ChangeEvent<HTMLInputElement>) => void
onTextChange(val: string) => void
placeholderReactNode
readOnlyboolean
rightElementReactNode
rightElementContainerPropsHTMLAttributes<HTMLDivElement> & { ref?: MutableRefObject<HTMLDivElement>; }
type"number" | "text" | "password"text
valuestring
wrapperPropsWrapperProps
TextFieldCharCount
Prop nameTypeDefaultDescription
asany
Tag or component, but a simple tag (i.e. built-in components, e.g. div, span) is recommended.
outOfnumber
TextFieldClear
Prop nameTypeDefaultDescription
asany
Tag or component, but a simple tag (i.e. built-in components, e.g. div, span) is recommended.
colorTypeColorTypes
Set color based on theme. If color is specified, that prop is used instead of this.
disabledboolean
Equivalent to button's disabled property.
keyboardClickKeysstring[]
loadingboolean
onBlurFocusEventHandler<HTMLDivElement>
onClickMouseEventHandler<HTMLDivElement>
onKeyDownKeyboardEventHandler<HTMLDivElement>
onKeyUpKeyboardEventHandler<HTMLDivElement>
onMouseDownMouseEventHandler<HTMLDivElement>
onMouseLeaveMouseEventHandler<HTMLDivElement>
onMouseUpMouseEventHandler<HTMLDivElement>
onReleaseEventHandler<SyntheticEvent<HTMLDivElement, Event>>
Callback that's triggered after click i.e. mouseup and keyup of enter or space.
onTouchEndTouchEventHandler<HTMLDivElement>
onTouchStartTouchEventHandler<HTMLDivElement>
radiusstring
sizeIconButtonSizes
tooltipReactNode
tooltipPropsOmit<TooltipProps, "title" | "children">
variantIconButtonVariantsflat
    Example
    Example
    Basic Usage
    Basic Usage
    Full width
    Full width
    Disabled state
    Disabled state
    Invalid state
    Invalid state
    Addons
    Addons
    References
    References
    API
    API
    TextField
    TextField
    TextFieldCharCount
    TextFieldCharCount
    TextFieldClear
    TextFieldClear
Coral is a thoroughly developed design system widely adopted by developers and designers for creating beautiful and user-friendly Sea internal products.

Copyright © 2018-2025 Sea Labs