Skip to main content

Overview

SaaS Starter Vue provides a complete form system with validation support. Forms are built using vee-validate for validation logic and zod for schema definition, integrated with Inertia.js form handling.

Form Validation Stack

  • vee-validate - Form validation library
  • @vee-validate/zod - Zod integration for vee-validate
  • zod - TypeScript-first schema validation
  • Inertia.js useForm - Server-side validation and form state

Basic Form Example

Here’s a simple login form using Inertia.js form handling:

Input Component

The Input component supports all standard HTML input attributes:

Input Props

  • modelValue - v-model binding
  • type - Input type (text, email, password, etc.)
  • placeholder - Placeholder text
  • disabled - Disabled state
  • class - Additional CSS classes

Input States

Textarea Component

For multi-line text input:

Select Component

Dropdown selection using reka-ui:

Checkbox Component

For boolean selections:
From resources/js/pages/system/auth/Login.vue:82-87:

Switch Component

Toggle switches for on/off states:

Radio Group

For selecting one option from multiple choices:

Form with Client Validation

Using vee-validate with zod schemas:

Form with Inertia.js

Combining Inertia.js form handling with components:

Label Component

Accessible form labels with proper associations:
Labels automatically handle:
  • Click-to-focus behavior
  • ARIA associations
  • Disabled state styling
  • Screen reader support

Form Structure Components

For organized form layouts:

Input Error Display

The InputError component displays validation errors:

File Upload

Handling file uploads with preview:

Best Practices

  1. Always use labels - Provide accessible labels for all form fields
  2. Show validation errors - Display clear error messages near the relevant field
  3. Disable on submit - Prevent double submissions by disabling the submit button
  4. Reset on success - Clear sensitive fields after successful submission
  5. Use appropriate input types - email, password, tel, etc. for better UX
  6. Add autocomplete - Help users fill forms faster
  7. Provide placeholder text - Give users context about expected input

Accessibility

All form components include:
  • Proper ARIA attributes
  • Keyboard navigation
  • Focus indicators
  • Error announcements
  • Label associations