# FormField

> Wraps a control with a label, help/error text and id wiring, so a screen reader gets the full picture without manual aria plumbing.

- Package: `fancy-ui-vue` (Vue 3.5+ + Tailwind CSS v4)
- Category: Forms
- Tags: form, field, label, validation, accessibility, compound
- Dependencies: label
- Types: `FormFieldProps`
- Docs: https://fancy-ui.rama.app/docs/components/form-field
- Source: https://github.com/RamaHerbin/fancy-ui/tree/main/vue/src/components/form-field

## Import

```vue
<script setup lang="ts">
import { FormField } from 'fancy-ui-vue';
</script>
```

Setup (once per project): `npm install fancy-ui-vue`, then put these lines in your main CSS file (the stylesheet imports go right after `@import "tailwindcss";`):

```css
@import "tailwindcss";
@import "fancy-ui-vue/tailwind.css";
@import "fancy-ui-vue/styles.css";
```

Full guide: https://fancy-ui.rama.app/llms.txt

The names below are the ones to write in a Vue template; when one differs from the Svelte name, the Svelte name follows in parentheses. Snippets become named slots (`#default` is the default snippet), a prop the Vue port declares as a model is a `v-model:<name>` (except `ref`, exposed via `defineExpose({ ref })`: put a template ref on the component and read `.ref`) and callbacks are listeners (`onclick` is `@click`). Every component sets `inheritAttrs: false`: `class` is a declared prop, merged where the Svelte component applies it (not always the root element), and only when the props table below lists it; other attributes do not fall through unless the package README lists the component as forwarding native attributes. Divergences: https://github.com/RamaHerbin/fancy-ui/tree/main/vue#divergences-from-the-svelte-api

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `label` | `string` | — | Label text — the common case. For custom label markup, render a Label in children instead |
| `description` | `string` | — | Help text under the control, replaced by error while the field is invalid |
| `error` | `string` | — | Error text. Setting it marks the field invalid and replaces the help text |
| `valid` | `boolean` | `false` | Decorative checkmark next to the help text; error always wins if both are set |
| `required` | `boolean` | `false` | Marks the field required: the label gets an asterisk, the control gets aria-required |
| `disabled` | `boolean` | `false` | Disables the field: reaches the wrapped control through context |
| `id` | `string` | — | Opts out of the generated id. description/error ids are suffixes of this same value |
| `class` | `string` | — | Additional CSS classes, merged onto the root |
| `ref` | `HTMLDivElement \| null` | `null` | Bindable reference to the root element |

## Slots

| Slot | Description |
| --- | --- |
| `#default` (Svelte `children`) | The control |

## Example

```vue
<script setup lang="ts">
import { FormField, Input } from "fancy-ui-vue";
</script>

<template>
	<FormField label="Email" description="We'll only use this to send your receipt.">
		<Input type="email" placeholder="you@example.com" />
	</FormField>
</template>
```
