Form Components
Form input components for collecting user data with consistent styling and validation support.Input
A text input field with label and validation support.Usage
Props
Unique identifier for the input field. Used for both
id and name attributes.Label text displayed above the input field
HTML input type (e.g., “text”, “email”, “password”, “number”, “tel”, “url”)
Placeholder text shown when input is empty
If
true, marks the field as required with a red asterisk and HTML5 validationFeatures
- Label with Required Indicator: Red asterisk (*) shown when
requiredis true - Focus States: Blue border on focus (
focus:border-blue-500) - Dark Mode: Automatically adapts background and text colors
- Smooth Transitions: 300ms transition on all state changes
- Full Width: Takes up 100% of parent container
- Accessible: Proper label-input association via
forandid
Styling Classes
The input uses comprehensive Tailwind classes:Dark Mode Colors
- Border:
dark:border-[#353a52]→dark:focus:border-blue-800 - Background:
dark:bg-[#10172d] - Text:
dark:text-gray-200
Label Implementation
Source Reference
Location:~/workspace/source/components/form/Input.vue:1
Textarea
A multi-line text input field for longer content.Usage
Props
Unique identifier for the textarea field. Used for both
id and name attributes.Label text displayed above the textarea
Placeholder text shown when textarea is empty
If
true, marks the field as required with a red asterisk and HTML5 validationFeatures
- Fixed Height: 5 rows by default (
rows="5") - Consistent Styling: Matches Input component styling
- Label with Required Indicator: Red asterisk shown when required
- Focus States: Blue border on focus
- Dark Mode: Automatic color adaptation
- Full Width: 100% width of parent container
- Resizable: Browser default resize behavior (can be controlled with CSS)
Styling Classes
Identical to Input component for visual consistency:Source Reference
Location:~/workspace/source/components/form/Textarea.vue:1
Form Validation Example
Here’s how to use both components in a complete form:Accessibility
Both components follow accessibility best practices:Label Association
Every input has a properly associated label:Required Fields
Required fields are indicated both visually and semantically:- Visual: Red asterisk in label
- Semantic:
requiredattribute on input element
Focus Management
- Clear focus states with blue borders
- No
outline-0without alternative focus indication - Keyboard navigation fully supported
Customization
Disable Resize on Textarea
Add a class to prevent resizing:Custom Styling
Both components accept additional classes:Validation States
For custom validation feedback, wrap in a container:Best Practices
Input Component
- Always provide a descriptive
label - Use appropriate
typefor the data being collected - Use
placeholderfor examples, not instructions - Mark truly required fields with
:required="true" - Provide clear error messages for validation failures
Textarea Component
- Use for content longer than one line
- Set appropriate
placeholderto guide users - Consider adding
maxlengthattribute for character limits - Provide character count for limited-length fields
Form Design
- Group related fields together
- Use Stack component for consistent spacing
- Place submit button at the end
- Provide feedback on submission (success/error)
- Disable submit button during processing
- Clear form after successful submission
TypeScript Support
Both components use<script setup lang="ts"> for TypeScript support: