Skip to content
synccn

Form Field

Label, description and error wired to any control, with ARIA handled.

Contact us

Fields marked * are required.

We only use this to reply.

0/300

Installation

$ pnpm dlx shadcn@latest add @synccn/form-field

First time in this project? Connect synccn with one command.

Usage

import { FormField, FieldSet } from "@/components/ui/form-field";<FormField label="Email" error={errors.email}>  <Input /></FormField>

API reference

Generated from the component's TypeScript types, so it always matches the code.

FormField

Label, control, description and error in one consistent block. The control gets the right id, aria-invalid and aria-describedby for free.

  • label
    React.ReactNode

    Field label.

  • description
    React.ReactNode

    Help text, hidden while there's an error.

  • error
    React.ReactNode

    Error message; also marks the control invalid.

  • required
    boolean

    Adds an asterisk and aria-required.

  • optional
    boolean

    Adds “(optional)” after the label.

  • childrenrequired
    React.ReactElement<any>

    The control. It receives id and ARIA attributes.

  • className
    string

    Extra classes for the root element.

FieldSet

Groups related fields under a heading, like a fieldset.

  • legend
    React.ReactNode

    Group heading.

  • description
    React.ReactNode

    Text under the heading.

  • children
    React.ReactNode

    Content to render.

  • className
    string

    Extra classes for the root element.

Dependencies

Read from the component's imports when the site builds. The CLI installs all of these for you.

Helpers

npm packages

Accessibility

From the source

Read from this component's code when the site builds, so it can't drift.

  • ARIA roles: alert
  • Labels are tied to their controls
  • Announces changes to screen readers