Field
Loading example…
Field is part of the Forms set, imported from @jcsoftdev/ui/forms.
Import
Section titled “Import”import { Field } from "@jcsoftdev/ui/forms";Single-component entry points tree-shake to just this component: @jcsoftdev/ui/forms/field.
<Field label="Nombre del cliente" hint="Como aparecerá en la agenda"> <Input placeholder="Ej. Marco Salazar" /></Field>| Prop | Type | Default | Description |
|---|---|---|---|
label * |
ReactNode |
The label content: text or any node (an icon, a tooltip trigger). | |
hint |
string |
||
error |
string | null |
Message under the control; null and undefined mean no error. |
|
optional |
boolean |
Marks the field as optional by appending the localized marker to the label. | |
required |
boolean |
Marks the field as required: a visible * marker (hidden from assistive tech, which gets aria-required on the control instead). Native validation is not turned on. |
|
disabled |
boolean |
Disables the control and mutes the label. | |
id |
string |
Id of the control the label and messages belong to. Generated when omitted. | |
controlId |
string |
Same as id, for fields with several children: the control carrying this id gets the description and invalid wiring and is what the label points at. Without it the first input, select, textarea or ARIA widget inside the field is used. |
|
children * |
ReactNode |
One control element (a component, or input, select, textarea) receives id, aria-describedby and aria-invalid directly. Several children (or a fragment, a plain wrapper element, or text) are rendered as given and the first control is wired after mount. |
|
classNames |
Partial<Record<FieldPart, string>> |
Per-part classes merged with cn; consumer classes win. className still targets the root and is merged last. |
* marks a required prop.
It also accepts the native props of the element or primitive it renders (for example className, id, aria-* and event handlers).
Storybook stories
Section titled “Storybook stories”- Default
- With Error
- Hint And Error
- Optional
- With Select
- With Textarea
- Controlled Form
- Node Label And Several Children
- Explicit Control Id
- Required
- Disabled
Source
Section titled “Source”packages/ui/src/forms/field/field.tsx