Color Schemes for Input
are not implemented in the default theme. You can extend the theme to implement them.
Input
Input component is a component that is used to get user input in a text field.
The Input component is a multipart component. Read more about how to style multipart components in the style system docs.
This component has three parts: field
, addon
, and element
. You can find
more information in the source for the styles
here.
Example#
The following theme would add a background with the value red.200
to the
field, and remove the border of the addon
.
import { extendTheme } from '@chakra-ui/react'const theme = extendTheme({components: {Input: {baseStyle: {field: {bg: 'red.200',},addon: {border: 'none',},},},},})
Props#
The Input
component composes Box so you can
pass all Box
props, and React.InputHTMLAttributes
.
colorScheme
colorScheme
string
errorBorderColor
errorBorderColor
The border color when the input is invalid. Use color keys in `theme.colors` @example errorBorderColor = "red.500"
string
focusBorderColor
focusBorderColor
The border color when the input is focused. Use color keys in `theme.colors` @example focusBorderColor = "blue.500"
string
htmlSize
htmlSize
The native HTML size
attribute to be passed to the input
number
isDisabled
isDisabled
If true
, the form control will be disabled. This has 2 side effects:
- The FormLabel
will have `data-disabled` attribute
- The form element (e.g, Input) will be disabled
boolean
isInvalid
isInvalid
If true
, the form control will be invalid. This has 2 side effects:
- The FormLabel
and FormErrorIcon
will have `data-invalid` set to true
- The form element (e.g, Input) will have `aria-invalid` set to true
boolean
isReadOnly
isReadOnly
If true
, the form control will be readonly
boolean
isRequired
isRequired
If true
, the form control will be required. This has 2 side effects:
- The FormLabel
will show a required indicator
- The form element (e.g, Input) will have `aria-required` set to true
boolean
size
size
"lg" | "md" | "sm" | "xs"
"md"
variant
variant
"outline" | "filled" | "flushed" | "unstyled"
"outline"
The Input component is a multipart component. Read more about how to style multipart components in the style system docs.
This component has three parts: field
, addon
, and element
. You can find
more information in the source for the styles
here.
Example#
The following theme would add a background with the value red.200
to the
field, and remove the border of the addon
.
import { extendTheme } from '@chakra-ui/react'const theme = extendTheme({components: {Input: {baseStyle: {field: {bg: 'red.200',},addon: {border: 'none',},},},},})