Input
The input is a standard text field that allows a user to write or edit text.
It should be used within the Form Control component to provide an accessible label and error states.
If the expected input could be more than one line, use the Textarea component.
Import
import { Input } from '@outfitio/outkit';
Usage
Input sizes
Use the size prop to change the size of the button. You can set the value to sm (32px), md (default, 40px), or
lg (48px).
Input icons
You can add icons to the left and right of the input component to provide additional context by wrapping the input in an
InputGroup alongside InputLeftElement and/or InputRightElement.
Input buttons
InputLeftElement and InputRightElement can also be used to render a button inside an input.
Input addons
You can add addons to the left and right of the input component to provide additional context by wrapping the input in
an InputGroup alongside InputLeftAddon and/or InputRightAddon.
Disabled Input
Read Only Textarea
Invalid Textarea
Accessibility
- Screen readers convey information about input automatically through native HTML.
- Use the
isDisabledprop to add the HTML disabled attribute to the input. - Use the
isReadOnlyprop to add the HTML readonly attribute to the input.
Best Practice
Inputs should:
- Be used within the Form Control component to provide an accessible label and error states.
- Be clearly labeled so that it is obvious to users what they should enter into the field
- Be labeled as 'Optional' if the input is not required
Props
The Input component composes PseudoBox so you can pass all PseudoBox props, and
React.InputHTMLAttributes.
| Name | Type | Default | Description |
|---|---|---|---|
as | React.ElementType | input | The component to use in place of input. |
aria-label | string | Accessibility label to use, in scenarios where the input has no visible label. A11y: It's usefult for screen readers. | |
aria-describedby | string | Accessibility label to use, in scenarios where the input has no visible label. A11y: It's usefult for screen readers. | |
isDisabled | boolean | false | If true, the input will be disabled. This sets aria-disabled=true and you can style this state by passing _disabled prop. |
isInvalid | boolean | false | If true, the input will indicate an error. This sets aria-invalid=true and you can style this state by passing _invalid prop. |
isRequired | boolean | false | If true, the input element will be required. |
isFullWidth | boolean | false | If true, the input element will span the full width of it's parent. |
isReadOnly | boolean | false | If true, prevents the value of the input from being edited. |
size | sm, md, lg | md | The visual size of the input element. |
variant | outline, unstyled, flushed, filled | outline | The variant of the input style to use. |
focusBorderColor | string | The border color when the input is focused. | |
errorBorderColor | string | The border color when isInvalid is set to true. |