Overview
Required
This appears in your workspace switcher.
Use lowercase letters, numbers, and dashes only.
Installation
pnpm dlx shadcn-vue@latest add input pnpm dlx shadcn-vue@latest add "https://ui.stackhacker.io/r/form-field.json"
Usage
<script setup lang="ts">
import { FormField } from '@/components/form-field'
import { Input } from '@/components/ui/input'
</script>
<template>
<FormField
v-slot="field"
label="Email"
description="Use your work email."
error="Enter a valid email address."
>
<Input v-bind="field" type="email" />
</FormField>
</template>With Form
When used inside Form, the name prop matches the current form errors.
<Form :state="state" :validate="validate">
<FormField v-slot="field" label="Email" name="email">
<Input v-model="state.email" v-bind="field" />
</FormField>
</Form>Slot Props
FormField passes accessibility props to the default slot so the slotted control can receive a stable id, invalid state, and description/error references.
| Prop | Description |
|---|---|
id | Generated control id. |
name | Field name. |
disabled | Whether the parent form is disabled. |
aria-invalid | ARIA invalid state for the control. |
aria-describedby | Description, help, or error ids for the control. |
API Reference
Props
| Prop | Type | Default | Description |
|---|---|---|---|
name | string | — | Field name used to match form errors. |
errorPattern | RegExp | — | Optional pattern for matching related error names. |
label | string | — | Field label. |
description | string | — | Supporting copy below the label. |
help | string | — | Help text shown when no error is present. |
hint | string | — | Text shown next to the label. |
error | string | boolean | — | Explicit error. Overrides form context errors. |
required | boolean | false | Shows a required marker. |
orientation | 'vertical' | 'horizontal' | 'responsive' | 'vertical' | Field layout orientation. |
class | string | — | Additional CSS classes. |
Slots
| Slot | Description |
|---|---|
default | Form control. Receives accessibility slot props. |
label | Custom label content. |
description | Custom description content. |
help | Custom help content. |
hint | Custom hint content. |
error | Custom error content. |

