Input Box
InputBox provides the visual container and styling for text input fields. It handles the box appearance, states (focus, error, disabled), and positioning of prefix/suffix elements.InputBox is an internal component used by Input, TextArea, Select, and other form controls. Most developers should use those higher-level components instead.
Installation
Usage
With Prefix Icon
Add an icon before the input:With Suffix Text
Add text after the input:Error State
Disabled State
Read-Only State
Inverse Variant
For use on dark backgrounds:With Prefix and Suffix
Props
Element name for customization. This prop is required to ensure consistent styling across composite components.
The input element to wrap (input, textarea, select, etc.).
Applies disabled styling to the input box.
Applies read-only styling to the input box.
Applies error styling to indicate validation failure.
Content to display before the input (icons, text, etc.).
Content to display after the input (icons, text, etc.).
The input type, which may affect styling.
Visual variant. Use “inverse” for dark backgrounds.
Input Box Types
Thetype prop accepts standard HTML input types and affects how the input is styled.
Best Practices
Do
- Use InputBox as a foundation for building custom input components
- Always provide the
elementprop for customization support - Use insertBefore for icons that indicate input purpose (search, email, etc.)
- Use insertAfter for units, currency symbols, or validation icons
- Match the disabled/readOnly/hasError states with the actual input element
Don’t
- Don’t use InputBox directly in application code - use Input, TextArea, or Select
- Don’t put interactive elements in insertBefore/insertAfter without careful consideration
- Don’t forget to sync InputBox state props with the actual input element
- Don’t use for non-input form controls
States and Styling
InputBox provides visual styling for:- Default: Normal, unfocused state
- Focus: When the input receives focus
- Hover: Mouse hover state
- Disabled: Non-interactive state
- Read-only: View-only state
- Error: Validation error state
- Inverse: For dark backgrounds
Accessibility
- InputBox is purely presentational - accessibility is handled by the child input element
- Ensure child inputs have proper labels
- Use aria-invalid on the input when hasError is true
- Decorative icons in insertBefore/insertAfter should have decorative prop
- Ensure color contrast meets WCAG standards in all states