Veil UI
Components

Form

A vertical form layout with sections and a validation summary.

Installation

$ npx veil-ui@latest add form

Usage

import { Form, FormSection, FormError } from "@/components/ui/form";

<Form onSubmit={handleSubmit}>
  <FormSection title="Profile" description="How you appear to teammates.">
    {fields}
  </FormSection>
  <FormError>Check the highlighted fields.</FormError>
</Form>;

Examples

Basic

Sections

Profile

How your account appears to teammates.

Notifications

Choose what lands in your inbox.

With error summary

Place the summary above the fields so keyboard and screen-reader users reach it first.

API reference

Form

PropTypeDefaultDescription
noValidatebooleantrueSkips native validation so you can render your own messages.
...propsReact.ComponentProps<"form">—All native form attributes, including onSubmit and action.

FormSection

PropTypeDefaultDescription
titleReact.ReactNode—Optional section heading.
descriptionReact.ReactNode—Optional supporting copy below the heading.

Accessibility

  • Validation messages use role="alert", so they are announced when they appear.
  • Use real <label> elements through FormField; placeholders are not labels.
  • Keep the submit button inside the form so Enter submits from any field.

Vue and plain HTML

This component also ships for Vue (Reka UI) and plain HTML. Install it with npx veil-ui add form --framework vue or switch the framework in components.json.

<script setup lang="ts">
import { cn } from "@/lib/utils";

defineOptions({ inheritAttrs: false });

const props = withDefaults(
  defineProps<{
    /** Skip native constraint validation and handle it yourself. */
    noValidate?: boolean;
    class?: string;
  }>(),
  { noValidate: true },
);
</script>

<template>
  <form
    data-slot="form"
    :novalidate="noValidate"
    :class="cn('grid gap-6', props.class)"
    v-bind="$attrs"
  >
    <slot />
  </form>
</template>

On this page