Input
Retrieve text input from a user.
The Input contain an additional Hooks, see subsection useInput for details.
General
Basic input field.
Sizes
Inputs of different sizes.
Set width
Specify width or other styles.
unwritable
Disable interactive inputs.
inline label
Show a short label in the line.
block label
Labels for custom styles.
Type
Differentiate states by color.
Icon
Specify an icon component.
Clearable
Add a clear button in the input box.
Password
Get Change
Capture changes in input.
Imperative API
Update component in an uncontrolled way.
APIs
Input.Props
Attribute | Description | Type | Accepted values | Default |
---|---|---|---|---|
value | input value | string | - | - |
initialValue | initial value | string | - | - |
placeholder | placeholder | string | - | - |
type | current type | InputTypes | InputTypes | default |
htmlType | native type attr | string | - | text |
readOnly | native attr | boolean | - | false |
disabled | disable input | boolean | - | false |
clearable | show clear icon | boolean | - | false |
label | text label for input | string | - | - |
labelRight | text label at right for input | string | - | - |
icon | icon for input | React.ReactNode | - | - |
iconRight | icon at right for input | React.ReactNode | - | - |
iconClickable | icons are clickable | boolean | - | false |
onIconClick | click icon event | (e: React.ChangeEvent) => void | - | - |
onChange | change event | (e: React.ChangeEvent) => void | - | - |
onClearClick | clear icon event | (e: React.MouseEvent) => void | - | - |
ref | forwardRef | Ref<HTMLInputElement | null> | - | - |
... | native props | InputHTMLAttributes | 'alt', 'type', 'className', ... | - |
Input.Password.Props
Attribute | Description | Type | Accepted values | Default |
---|---|---|---|---|
hideToggle | hide toggle icon | boolean | - | false |
... | input props | Input.Props | Input.Props | - |
InputTypes
type InputTypes = 'default' | 'secondary' | 'success' | 'warning' | 'error'
useInput
type useInput = (initialValue: string) => {
state: string
setState: Dispatch<SetStateAction<string>>
currentRef: MutableRefObject<string>
reset: () => void
bindings: {
value: string
onChange: (event: React.ChangeEvent<HTMLInputElement>) => void
}
}
Contributors