Components
Form
A vertical form layout with sections and a validation summary.
Installation
$ npx veil-ui@latest add formUsage
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
With error summary
Place the summary above the fields so keyboard and screen-reader users reach it first.
API reference
Form
| Prop | Type | Default | Description |
|---|---|---|---|
| noValidate | boolean | true | Skips native validation so you can render your own messages. |
| ...props | React.ComponentProps<"form"> | — | All native form attributes, including onSubmit and action. |
FormSection
| Prop | Type | Default | Description |
|---|---|---|---|
| title | React.ReactNode | — | Optional section heading. |
| description | React.ReactNode | — | Optional supporting copy below the heading. |
Accessibility
- Validation messages use
role="alert", so they are announced when they appear. - Use real
<label>elements throughFormField; 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>