Trên trang này

Trang này chưa có bản tiếng Việt, nội dung bên dưới là bản tiếng Anh. Xem trang tiếng Anh

Biểu mẫu

Install, props and the parts Form is built from.

Install

Run this in the app, after shadcn-vue init and the Beehexa theme (Button › Code). It also installs Label, vee-validate, @vee-validate/zod and zod.

npx shadcn-vue@latest add https://beehexa.design/r/form.json

Use

<script setup lang="ts">
import { toTypedSchema } from '@vee-validate/zod'
import { useForm } from 'vee-validate'
import { z } from 'zod'
import { Button } from '@/components/ui/button'
import { FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage } from '@/components/ui/form'
import { Input } from '@/components/ui/input'

const { handleSubmit } = useForm({
  validationSchema: toTypedSchema(z.object({
    storeName: z.string({ required_error: 'Enter the store name.' }).min(2, 'Enter at least 2 characters.'),
  })),
})
const onSubmit = handleSubmit(values => console.log(values))
</script>

<template>
  <form novalidate @submit="onSubmit">
    <FormField v-slot="{ componentField }" name="storeName">
      <FormItem>
        <FormLabel>Store name</FormLabel>
        <FormControl>
          <Input v-bind="componentField" />
        </FormControl>
        <FormDescription>Shown on invoices.</FormDescription>
        <FormMessage />
      </FormItem>
    </FormField>
    <Button type="submit">Save</Button>
  </form>
</template>

Parts

Part What it does
FormField vee-validate Field. name picks the value; its slot gives componentField to bind on the control
FormItem One field. Gives the ids to the parts inside
FormLabel The Label, pointed at the control. Sets data-error when there is an error, without changing its colour
FormControl Wraps the control and sets its id, aria-invalid and aria-describedby
FormDescription Help text under the control
FormMessage The field’s error, from vee-validate
Form, FormFieldArray vee-validate Form and FieldArray, exported as they are

All styled parts take class.

Built on

The shadcn-vue Form API (shadcn-vue registry, style reka-nova, read 12 November 2026), on vee-validate 4 with @vee-validate/zod. Beehexa changes only the styles: the same as Field. The label does not turn red on an error.