Installation
Usage
Props
Sets the input type. Supports all HTML5 input types including
text, email, password, number, tel, url, search, date, time, etc.Sets the id of the input. Should match the
htmlFor of the Label component.Sets the name attribute of the input for form submission.
The controlled value of the input.
The default value for uncontrolled inputs.
Placeholder text displayed when the input is empty.
Disables the input, preventing user interaction.
Makes the input read-only. Users can see but not modify the value.
Marks the input as required for form validation.
Sets the input to an error state with error styling.
Used to add a prefix to the input, such as an icon or text.
Used to add a suffix to the input, such as an icon or text.
Visual style variant. Use
inverse for dark backgrounds.Callback fired when the input value changes.
Callback fired when the input receives focus.
Callback fired when the input loses focus.
Overrides the default element name for customization.
Number Input Props
Minimum value for number inputs.
Maximum value for number inputs.
Step increment for number inputs.
Accessible label for the increment button on number inputs.
Accessible label for the decrement button on number inputs.
Examples
With Prefix/Suffix
Error State
Number Input
Accessibility
- Always pair Input with a Label component using matching
idandhtmlForprops - Use
requiredprop to mark required fields and include RequiredDot in Label - Provide helpful error messages with HelpText in error variant
- Use appropriate input types for better mobile keyboard experience
- Ensure sufficient color contrast in both default and inverse variants
- Support keyboard navigation and screen reader announcements
Best Practices
- Use specific input types (email, tel, url) to improve mobile UX with appropriate keyboards
- Always provide clear labels and help text
- Use placeholder text sparingly - it should not replace labels
- Show validation errors inline with clear, actionable messages
- Consider using insertBefore/insertAfter for common patterns like search icons or currency symbols
- For number inputs, ensure min/max values are multiples of the step value