Input
An input enables a person to type in text information.
When to use
- When a person should provide information to the application.
Examples
You can pass accept
prop to native input using Override which isn't exposed in the main API.
As with many of our components, there is also an uncontrolled version, StatefulInput
, which manages its own state.
API
Input props
Name | Type | Default | Description |
---|---|---|---|
animate | boolean | false | Enable animation for certain parts of input. e.g. shows animated border on hover for ai intent |
aria-describedby | string | Sets aria-describedby attribute. | |
aria-label | string | Sets aria-label attribute. | |
aria-labelledby | string | Sets aria-labelledby attribute. | |
autoComplete | string | Determines if browser should provide value suggestions. | |
autoFocus | string | Takes "start" | "end" | number | boolean values and sets the position of the cursor on mount. | |
className | string | className to modify style of Input container | |
clearable | boolean | false | If true, adds a clear value icon button to the end of the input container. |
debounceInterval | number | debouncedOnChange function will be called after onChange stops being called for this duration in milliseconds. | |
debouncedOnChange | function | Debounced handler of onChange. Specify interval with `debounceInterval` prop. | |
disabled | boolean | false | Renders component in disabled state. |
draggable | boolean | false | Set it to true if the input is rendered in a dnd component. When true, onDragStart's default behaviour will be prevented. |
endEnhancer | function | An input helper rendered after and attached to the input field. | |
id | string | Id attribute value to be added to the input element and as a label's for attribute value. | |
inputMode | string | A hint as to the type of data that might be entered by the user while editing the element or its contents. | |
inputRef | ref | A ref to access an input element. | |
intent | 'default' | 'success' | 'warning' | 'error' | 'ai' | Defines the intent of the Input. | |
max | string | max value when used as input type=number | |
maxCharLimit | number | Maximum character needed | |
min | string | min value when used as input type=number | |
name | string | Name attribute. | |
onBlur | function | Called the onBlur event triggers. | |
onChange | function | Called when input value is changed. | |
onFocus | function | Called the onFocus event triggers. | |
onKeyDown | function | Called the onKeyDown event triggers. | |
onKeyPress | function | Called the onKeyPress event triggers. | |
onKeyUp | function | Called the onKeyUp event triggers. | |
overrides | custom | Lets you customize all aspects of the component. | |
pattern | string | A regex that is used to validate the value of the input on form submission. | |
placeholder | string | Input's placeholder. | |
required | boolean | false | Renders component in required state. |
size | 'xs' | 'sm' | 'md' | Input's size. SPACIOUS | COMFORTABLE -> md, COMPACT -> xxxs, DEFAULT -> md | |
startEnhancer | function | An input helper rendered before and attached to the input field. | |
style | string | className to modify style of Input container | |
type | string | Input type attribute. | |
value | string | Input value attribute. | |
variant | 'default' | 'line' | Input's variant - default, line |
You can check the implementation of the component for more details.
Input exports
You can import this module like so:
import {ADJOINED} from 'spaceweb/input'
It exports the following components or utility functions:
- ADJOINED
- BaseInput
- CUSTOM_INPUT_TYPE
- ENHANCER_POSITION
- Input
- InputContainer
- MaskedInput
- STATE_CHANGE_TYPE
- StatefulInput
- StyledEndEnhancer
- StyledInput
- StyledInputContainer
- StyledInputEnhancer
- StyledRoot
- StyledStartEnhancer