ValyroUI Русская версия

Form Field

Field with validation and errors. Free, MIT · Forms and input › Whole forms and filters

Installation

npx valyro-cli@latest add form-field
npx shadcn@latest add https://valyro.xyz/r/form-field.json
npm install valyro-ui

import 'valyro-ui/styles.css';
import { FormField } from 'valyro-ui';

Props

PropTypeDefault
labelReactNodeText of the <label> above the control, linked to it by id. Or FormField.Label.
hintReactNodeHelper text under the control, linked via aria-describedby. Hidden while error is set. Or FormField.Description.
errorReactNodeError message; any truthy value marks the field invalid and replaces the hint. Or FormField.Error.
requiredbooleanfalseShows a required mark next to the label and tells screen readers: aria-required on the control, or the labels.required word in its description where its role has no aria-required.
counterReactNodeSlot at the end of the footer, e.g. a character counter "42/280".
children *ReactNodeA single control. It receives id, aria-describedby, aria-invalid and, for components, invalid. Or the compound form: FormField.Label, FormField.Control (around the control), FormField.Description, FormField.Error.
labelsPartial<FormFieldLabels>Overrides for the built-in English text; keys left out keep their defaults.

Compound parts

FormField.Label (FormFieldLabel), FormField.Control (FormFieldControl), FormField.Description (FormFieldDescription), FormField.Error (FormFieldError)

Related components

Previous: Image Cropper · Next: Multi-step Form · All Forms and input