Skip to content

Form Field ​

Styled form field relationship built on the form-field primitive.

@zeus-web/form-fieldData Entryzweb add form-fieldGenerated

Playground ​

Source ​

Choose the framework entry that matches your application.

html
<script type="module">
  import '@zeus-web/form-field/wc/auto'
</script>

<zw-form-field invalid
  ><zw-form-field-label>Email</zw-form-field-label
  ><zw-form-field-control><input type="email" /></zw-form-field-control
  ><zw-form-field-message
    >Enter a valid email.</zw-form-field-message
  ></zw-form-field
>
tsx
import {
  FormField,
  FormFieldControl,
  FormFieldLabel,
  FormFieldMessage,
} from '@zeus-web/form-field/react'

export function FormFieldExample() {
  return (
    <FormField invalid>
      <FormFieldLabel>Email</FormFieldLabel>
      <FormFieldControl>
        <input type="email" />
      </FormFieldControl>
      <FormFieldMessage>Enter a valid email.</FormFieldMessage>
    </FormField>
  )
}
vue
<script setup lang="ts">
import {
  FormField,
  FormFieldControl,
  FormFieldLabel,
  FormFieldMessage,
} from '@zeus-web/form-field/vue'
</script>

<template>
  <FormField invalid
    ><FormFieldLabel>Email</FormFieldLabel
    ><FormFieldControl><input type="email" /></FormFieldControl
    ><FormFieldMessage>Enter a valid email.</FormFieldMessage></FormField
  >
</template>

Add ​

bash
zweb add form-field

Imports ​

Styled registry component:

tsx
import { FormField } from '@/components/ui/form-field'

Primitive React wrapper:

tsx
import { FormField } from '@zeus-web/form-field/react'

Web Component entry:

ts
import '@zeus-web/form-field/wc/auto'

Props ​

PropTypeDefaultDescription
idstring-Stable field identifier.
invalidboolean-Marks the field as invalid.
disabledboolean-Disables the associated control.
requiredboolean-Marks the associated control as required.

Events ​

No public events documented.

Slots ​

SlotDescription
defaultLabel, description, control and message content.

Styling ​

Uses Tailwind: yes

Theme tokens:

  • border
  • background
  • foreground
  • ring

Internal selectors:

  • [data-slot=form-field]

Registry ​

Registry source: available.

Add command: zweb add form-field

Type: component

Dependencies:

  • @zeus-web/form-field

Registry dependencies:

  • cn
  • globals

Files:

  • templates/react/form-field.tsx → components/ui/form-field.tsx
  • templates/vue/form-field.ts → components/ui/form-field.ts

AI usage rules ​

Do:

  • Use the copied Registry wrapper for styled application UI.

Do not:

  • Do not assume the headless primitive provides final visual styling.

Examples ​

React styled usage ​

tsx
import {
  FormField,
  FormFieldControl,
  FormFieldLabel,
} from '@/components/ui/form-field'

export function Example() {
  return (
    <FormField required>
      <FormFieldLabel>Work email</FormFieldLabel>
      <FormFieldControl>
        <input type="email" />
      </FormFieldControl>
    </FormField>
  )
}

Released under the MIT License.