The Input component is a versatile form input field that supports labels, validation states, prefix/suffix elements, and various styling options. It's designed to provide a consistent and accessible input experience across your application.
import { Input } from '@dashflowx/core'export default function InputExample() {return (<Inputplaceholder="Enter your name"lable="Full Name"/>)}
Preview:
| Prop | Type | Default | Description |
|---|---|---|---|
placeholder | string | 'Enter text...' | Placeholder text for the input |
disabled | boolean | false | Whether the input is disabled |
fullwidth | boolean | false | Whether the input takes full width |
lable | string | '' | Label text for the input |
required | boolean | false | Whether the input is required |
sucessMsg | string | '' | Success message to display |
errorMsg | string | '' | Error message to display |
prefixElement | string | '' | Prefix element (icon, text, etc.) |
sufixElement | string | '' | Suffix element (icon, text, etc.) |
className | string | '' | Additional CSS classes |
...props | HTMLInputElement | - | All standard input HTML attributes |
<Inputplaceholder="Enter your email"lable="Email Address"required={true}/>
Preview:
<Inputplaceholder="Enter your name"lable="Full Name"sucessMsg="Name looks good!"fullwidth={true}/>
Preview:
Name looks good!
<Inputplaceholder="Enter your password"lable="Password"errorMsg="Password must be at least 8 characters"required={true}/>
Preview:
Password must be at least 8 characters
<Inputplaceholder="Search products..."lable="Search"prefixElement="🔍"sufixElement="⌨️"fullwidth={true}/>
Preview:
<Inputplaceholder="This field is disabled"lable="Disabled Field"disabled={true}fullwidth={true}/>
Preview:
<div className="space-y-4"><Inputplaceholder="Enter your email"lable="Email"required={true}fullwidth={true}/><Inputplaceholder="Enter your password"lable="Password"type="password"required={true}fullwidth={true}/></div>
<Inputplaceholder="Search for products, brands, or categories..."lable="Search"prefixElement="🔍"fullwidth={true}className="mb-4"/>
<Inputplaceholder="Enter your phone number"lable="Phone Number"required={true}errorMsg="Please enter a valid phone number"fullwidth={true}/>
<Inputplaceholder="Custom styled input"lable="Custom Input"className="mb-6"fullwidth={true}/>
Always provide clear, descriptive labels for your inputs.
// ✅ Good - Clear label<Inputlable="Email Address"placeholder="Enter your email"required={true}/>// ❌ Avoid - Unclear label<Inputlable="Field 1"placeholder="Enter something"/>
Use placeholders that provide helpful guidance without being too verbose.
// ✅ Good - Helpful placeholder<Inputlable="Username"placeholder="Choose a unique username"/>// ❌ Avoid - Too verbose placeholder<Inputlable="Username"placeholder="Please enter a unique username that is at least 3 characters long and contains only letters and numbers"/>
Use success and error messages to provide clear feedback.
// ✅ Good - Clear validation feedback<Inputlable="Email"errorMsg="Please enter a valid email address"required={true}/>// ✅ Good - Success feedback<Inputlable="Username"sucessMsg="Username is available"/>
Use fullwidth consistently across your forms.
// ✅ Good - Consistent sizing<div className="space-y-4"><Input lable="First Name" fullwidth={true} /><Input lable="Last Name" fullwidth={true} /><Input lable="Email" fullwidth={true} /></div>
Ensure proper accessibility with required fields and clear labels.
// ✅ Good - Accessible input<Inputlable="Email Address"placeholder="Enter your email"required={true}errorMsg="Email is required"/>
You can customize the input appearance using CSS classes:
<Inputlable="Custom Input"className="mb-6"fullwidth={true}/>
Add icons or other elements to enhance the input:
<Inputlable="Price"prefixElement="$"sufixElement="USD"placeholder="0.00"fullwidth={true}/>
The Input component supports all standard HTML input types:
<Inputlable="Email"type="email"placeholder="Enter your email"fullwidth={true}/><Inputlable="Password"type="password"placeholder="Enter your password"fullwidth={true}/><Inputlable="Number"type="number"placeholder="Enter a number"fullwidth={true}/>
The Input component works well with popular form libraries:
// With React Hook Formimport { useForm } from 'react-hook-form';function MyForm() {const { register, handleSubmit } = useForm();return (<form onSubmit={handleSubmit(onSubmit)}><Inputlable="Email"{...register('email', { required: true })}fullwidth={true}/></form>);}
Use the Input component with validation patterns:
<Inputlable="Phone Number"placeholder="(555) 123-4567"pattern="[0-9]{3}-[0-9]{3}-[0-9]{4}"errorMsg="Please enter a valid phone number"fullwidth={true}/>
- TextArea: For multi-line text input
- Select: For dropdown selections
- Checkbox: For boolean selections
- RadioGroup: For single-choice selections
- Switch: For toggle selections
For the complete API reference and advanced usage patterns, see the Input API documentation.
