UNPKG

@navinc/base-react-components

Version:
29 lines (22 loc) 1.16 kB
All form-element components expect to be controlled components. This makes them immediately compatible with form managers like formik or redux-form, as well as within any stateful component. Use the `<Input />` component just as you would for any `input` type that accepts textual input (`radio`, `checkbox` have their own respective components). To enable label dynamicism, be sure to pass `touched` as a property based on the Formik detection of the field having been visited. All props get passed on to the underlying `input`. In addition to native form element attributes, all form-element components implement these props. Add a line of helper text below the input using `helperText` and `helperIcon`, and optionally convert the helper into a button using the `helperAction` to perform some work, such as showing and hiding a password. isInvalid: Boolean -- Indicates whether the value of the field is valid (`false`) or invalid (`true`) ``` <Input name="my-input" required isInvalid={this.state['my-input'].isInvalid} onChange={this.handleChange} value={this.state['my-input'].value} /> ``` TODO: Add some standardized onClick tracking?