Input
A Universal Input component that handles user inputs of all types, including using your own custom UI. This component is a thin wrapper that delegates rendering to other input controls.
It supports Universal Input API and adds extra elements, like help info, error messages and tooltip popup, for a consistent UX (user experience).
Props
Prop | Type | Default | Description |
---|---|---|---|
type | String |
| Native input |
id | String | Unique input identifier, default is string created from React.useId() | |
info | String |Number |Boolean |Function | Help information to show after the Input | |
error | String |Number |Boolean |Function | Error message to show after the Input (ex. on validation fail) | |
helpTransition | Boolean |Object |
| Whether to enable input info/error animation transition (or expandCollapse transition options) |
compact | Boolean | Whether to make input take only the minimum content width necessary | |
controlProps | Object | Props to pass to Input Control component | |
tooltip | String |Number |Boolean |Function |Object | Tooltip props (or content) to display as popup on interaction with this component |
Examples
Basic Usage
Input Types
Input Sizes
Input States
Input Values
Custom Input Type
Webframe universal Input
supports rendering with any custom input control. Add as many controls as you like without worrying about the bundle size because Webframe uses automatic code splitting that lazy loads components on the client side.
Setup
import { dynamicImport } from '@webframer/js'
import { Input } from '@webframer/ui'
// Define all custom Input controls in the project for lazy loading
Input.defaultProps.controls = dynamicImport({
'MyCustomInput': () => import (`./MyCustomInput.jsx`),
})
Usage
import { Input } from '@webframer/ui'
function Form () {
// Input `type` is case-sensitive, it is recommended
// to use CapCase naming convention for custom controls
return <Input type='MyCustomInput' />
}
Built-in Types
In addition to native browser input types (opens in a new tab) (ie. text
, number
, email
, etc.), these are Webframe built-in types with their corresponding components:
checkbox
→file
→select
→switch
→textarea
→upload
→