Skip to content

Search documentation

Search guides, examples, and component APIs.

Quick links
↑↓ NavigateEnter OpenEsc Close
Get started

Documentation navigation

Guide

Forms & accessibility

Create form state once, then give each control a name. Initial values, validation, errors, submit, and reset come from the selected provider.

Vee Validate rules

Call useForm with initial values and Vee Validate's own validator functions. The Input needs only a matching name to join the form. Vee Validate 5.0.0-beta.1 is an optional, exactly pinned peer dependency; install it only when you choose the Vee provider. Its Standard Schema support is still beta.

VeeForm.vue
<script setup lang="ts">
import { useForm } from 'vee-validate'
import Button from './components/ui/button/Button.vue'
import Form from './components/ui/form/Form.vue'
import Input from './components/ui/input/Input.vue'

useForm({
  initialValues: { email: '' },
  validationSchema: {
    email: (value: string) =>
      /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value) || 'Enter a valid email address.',
  },
})

function save(values: unknown) {
  // Send validated values to your server.
  console.log(values)
}
</script>

<template>
  <Form @submit="save">
    <label for="email">Email</label>
    <Input id="email" name="email" type="email" />
    <Button type="submit">Save</Button>
  </Form>
</template>

Select --form vee --form-schema custom during setup. You can also pass Zod, Yup, or Kern schemas directly to Vee Validate 5. Choose --form kern for Weini-owned form state, or use native controls and app-owned validation without a shared provider. Before changing the pinned Vee version, test field binding, schema adapters, validation errors, reset behavior, and a clean packed-package install.

Kern form state

Choose --form kern and call useKernForm with initial values and a Kern schema. The same named control API works with the Kern provider.

KernForm.vue
<script setup lang="ts">
import { useKernForm } from '@getweini/vue/primitives/form-kern'
import { object, string } from '@sousaivan/kern/validation'
import Button from './components/ui/button/Button.vue'
import Form from './components/ui/form/Form.vue'
import Input from './components/ui/input/Input.vue'

useKernForm({
  initialValues: { email: '' },
  schema: object({ email: string().email() }),
})

function save(values: unknown) {
  console.log(values)
}
</script>

<template>
  <Form @submit="save">
    <label for="kern-email">Email</label>
    <Input id="kern-email" name="email" type="email" />
    <Button type="submit">Save</Button>
  </Form>
</template>

The CLI installs the selected provider as Form.vue, so the template stays the same when you switch providers.

Labels, errors, and messages

Labels

Use a visible label. A placeholder is not a label.

Messages

Pass your app's text to MultiSelect and NumberInput. Select accepts messages for empty and clear states.

Errors

Named controls show provider errors and link them with aria-describedby.

Reset

A reset button restores the provider's initial values.

Give each control a visible label. Named controls show validation errors after blur or submit. Use the #error slot to customize the message. The Field wrapper was removed in registry 0.5.0; replace it with a native <label> connected to the named control using for and id.

MultiSelect submits repeated fields. Read them with FormData.getAll(name).