Dinachi

Field

A form field component that provides structure for labels, controls, descriptions, and error messages. Handles validation and accessibility automatically.

#Installation

npx @dinachi/cli@latest add field

#Usage

tsx
import { Field, FieldLabel, FieldControl, FieldDescription, FieldError, FieldValidity } from '@/components/ui/field'

#Examples

Default Field

A basic field with label, control, and description

We'll never share your email.

Field with Validation

Interactive field with real-time validation feedback

Must be at least 3 characters.

Field with Error

Field displaying an error state

Required Field

Fields marked as required with visual indicators

Your legal name as it appears on documents.

We'll use this for account recovery.

Disabled Field

Field in a disabled state

This field cannot be modified.

#API Reference

PropTypeDefaultDescription
namestringThe name of the field (required)
disabledbooleanfalseWhether the field is disabled
invalidbooleanfalseWhether the field is in an invalid state
requiredbooleanfalseWhether the field is required
validate(value: any) => string | undefinedCustom validation function that returns an error message or undefined