TextField

TextFields allow users enter and edit text inputs.

Simple TextFields

This is an informative helper text.

With InputAdornments

The InputAdornment can be used to add a prefix, a suffix, an action, or an icon to an input.

KG

Controlled TextField

You can use the value, and onChange properties to control the behaviour of the text field.

The value is
""

API

Learn more about the properties and the customization points.

Usage

import TextField from "@sonnat/ui/TextField";
//or
import { TextField } from "@sonnat/ui";

Properties

Note that the documentation avoids mentioning all the native props (there are a lot) in this section of the components.

TextField Properties
NameTypeDefaultDescription
classNamestring-Append to the class names applied to the component so you can override or extend the styles.
namestring-The name of the text field.
placeholderstring-The placeholder property of the text field.
valuestring-The value of the text field. The DOM API casts this to a string.
defaultValuestring-The default value. Use when the component is not controlled.
helperTextstring-The helper text content.
helperIconnode-The helper icon element placed before the helper text.
size"large"
| "medium"
| "small"
"medium"The size of the text field.
variant"filled"
| "outlined"
"outlined"The variant of the text field.
type"text"
| "email"
| "password"
| "number"
| "url"
"text"The type of the input.
leadingAdornmentnode-The leading adornment for this component.
This can be used to add a prefix, an action, or an icon to the leading of your input.
trailingAdornmentnode-The trailing adornment for this component.
This can be used to add a suffix, an action, or an icon to the trailing of your input.
roundedbooleanfalseIf true, the text field will be rounded.
disabledbooleanfalseIf true, the text field will be disabled.
readOnlybooleanfalseIf true, the text field will be readOnly.
focusedbooleanfalseIf true, the text field will be focused.
autoFocusbooleanfalseIf true, the text field will be focused on mount.
requiredbooleanfalseIf true, the text field will be required.
hasErrorbooleanfalseIf true, the text field will indicate invalid input.
fluidbooleanfalseIf true, the text field will be fluid (max-width: 100%)
inputPropsobject-The properties applied to the input element.
onChangefunction-The callback fires when the state has changed.
Signature: function(value: string) => void
  • The ref is forwarded to the root element.
  • Any other properties supplied will be provided to the root element.