Input Types
The form system supports various input types to handle different data formats and user interactions. Each input type has specific properties and behaviors.
Available Input Types
Type | Data Type | Use Case | Validation | Documentation |
---|---|---|---|---|
text | string | General text input | Email, regex, custom | Text Input |
number | number | Numeric values | Min/max, custom | Number Input |
select | any | Single choice from list | Required | Select Input |
radio | any | Single choice from options | Required | Radio Input |
switcher | boolean | Toggle on/off | None | Switcher Input |
static | any | Display only | None | Static Input |
container | object | Group fields | Nested validation | Container Input |
Quick Reference
Text Input
Basic text input field for string values.
typescript
{
name: 'username',
type: 'text',
label: 'Username',
placeholder: 'Enter username',
rules: ['required']
}
Number Input
Numeric input field for integer and decimal values.
typescript
{
name: 'age',
type: 'number',
label: 'Age',
placeholder: 'Enter your age',
rules: ['required']
}
Select Input
Dropdown selection with predefined options.
typescript
{
name: 'country',
type: 'select',
label: 'Country',
options: [
{ id: 1, text: 'Ukraine' },
{ id: 2, text: 'USA' }
],
rules: ['required']
}
Radio Input
Radio button selection for single choice from multiple options.
typescript
{
name: 'gender',
type: 'radio',
label: 'Gender',
options: [
{ id: 'male', text: 'Male' },
{ id: 'female', text: 'Female' }
],
rules: ['required']
}
Switcher Input
Toggle switch for boolean values.
typescript
{
name: 'notifications',
type: 'switcher',
label: 'Enable notifications'
}
Static Input
Read-only display field for showing values.
typescript
{
name: 'id',
type: 'static',
label: 'User ID',
value: '12345'
}
Container Input
Container for grouping related fields.
typescript
{
name: 'address',
type: 'container',
label: 'Address Information',
schema: [
{
name: 'street',
type: 'text',
label: 'Street Address',
rules: ['required']
},
{
name: 'city',
type: 'text',
label: 'City',
rules: ['required']
}
]
}
Option Interface
For select and radio inputs, options follow this interface:
typescript
interface IOption {
id: number | string; // Unique identifier
text: string; // Display text
color?: string; // Optional color for styling
}
Custom Input Types
You can extend the system with custom input types by:
- Creating a new input component
- Adding it to the inputs index
- Using the new type in your schema
Best Practices
- Choose appropriate input types for your data
- Use placeholders to guide user input
- Provide clear labels for all fields
- Group related fields using containers
- Set appropriate validation rules for each type
- Consider accessibility when choosing input types