Tonic UI
Getting StartedColor ModeColor StyleVersionsContributing
THEME
BordersBreakpointsColorsOutlinesPositionsSpacingSizesShadowsTypography
BUILDING BLOCKS
BoxControlBox
UTILITIES

Input

The Input component is used to get user input in a text field.

Import

Usage

EDITABLE EXAMPLE

Sizes

Use the size prop to change the size of the Input. You can set the value to sm, md, or lg.

EDITABLE EXAMPLE

Variants

The Input component comes in 3 variants: outline, filled, and unstyled. Pass the variant prop and set it to either of these values.

outline

EDITABLE EXAMPLE

filled

EDITABLE EXAMPLE

unstyled

EDITABLE EXAMPLE

Attributes

Standard input attributes are supported, e.g., type, disabled, readOnly, required, list, etc.

type

EDITABLE EXAMPLE

disabled

EDITABLE EXAMPLE

readOnly

EDITABLE EXAMPLE

required

EDITABLE EXAMPLE

list

The value of list is the id attribute of the <datalist> of autocomplete options. The HTML <datalist> element contains a set of <option> elements that represent the permissible or recommended options available to choose from within other controls.

EDITABLE EXAMPLE

Adornments

Input adornments can be used to add a prefix, a suffix or an action to an input. For instance, you can use an icon button to hide or reveal the password.

First, you may have to create your input adornment components for convenience. Note that you must use the z-index value as mentioned below.

Take a look at the following examples:

EDITABLE EXAMPLE

Validation

Use the isInvalid attribute to indicate that the value entered into an input field does not conform to the format expected by the application. isInvalid can also be used to indicate that a required field has not been filled in.

Set isInvalid to true on the fields that have failed validation, otherwise set it to false if no errors detected.

EDITABLE EXAMPLE

Props

NameTypeDefaultDescription
sizestring'md'The visual size of the input element. One of: 'sm', 'md', 'lg'
variantstring'outline'The variant of the input style to use. One of: 'outline', 'filled', 'unstyled'
disabledbooleanIf true, the user cannot interact with the control. This sets aria-disabled=true and you can style this state by passing the _disabled prop.
readOnlybooleanIf true, prevents the value of the input from being edited.
isInvalidbooleanIf true, the input will indicate an error. You can style this state by passing the _invalid prop.