Search documentation

Search the documentation and open a page.

Composes accessible labels, controls, descriptions, and validation messages for form fields.

Loading...

Installation

pnpm dlx shadcn@latest add @wirekyt/field

Composition

fieldset[appFieldSet] (optional) ├── legend[appFieldLegend] ├── [appFieldSetDescription] (optional) ├── [appFieldSetError] (optional) └── [appFieldGroup] or grouped control ├── [appField] or [appFieldItem] │ ├── label[appFieldLabel] │ │ └── [appFieldRequiredIndicator] (optional) │ ├── form control │ │ ├── [appFieldInput] │ │ ├── [appFieldSelect] │ │ └── textarea[appFieldTextarea] │ ├── [appFieldContent] (optional) │ │ ├── [appFieldTitle] or label[appFieldLabel] │ │ └── [appFieldDescription] (optional) │ ├── [appFieldDescription] (optional) │ └── [appFieldError] (optional) └── [appFieldSeparator] (optional)

Examples

Choice Cards

Loading...

Default

Loading...

Disabled

Loading...

Fieldset

Loading...

Orientation

Loading...

Validation

Loading...

API Reference

Apply the directives to native elements and use class plus the native attributes supported by the host element. FieldImports contains every styled directive and both context providers listed below.

[appField]

Inputs

InputTypeDefaultDescription
idstring | undefinedgeneratedUnique identifier used to create the field part IDs.
idsFieldElementIds | undefined—Overrides generated identifiers for the field parts.
requiredbooleanfalseMarks the associated control as required.
disabledbooleanfalseMarks the field and its associated control as disabled.
invalidbooleanfalseMarks the field and its associated control as invalid.
readOnlybooleanfalseMarks the associated control as read-only.
targetstring | undefined—Identifies the form control associated with the field.
orientation"vertical" | "horizontal" | "responsive""vertical"Controls the visual arrangement of the field parts.

fieldset[appFieldSet]

Inputs

InputTypeDefaultDescription
idstring | undefinedgeneratedUnique identifier used to connect the fieldset parts.
disabledbooleanfalseDisables the controls contained by the fieldset.
invalidbooleanfalseMarks the controls contained by the fieldset as invalid.

legend[appFieldLegend]

Inputs

InputTypeDefaultDescription
variant"legend" | "label""legend"Controls the legend's visual typography variant.

textarea[appFieldTextarea]

Inputs

InputTypeDefaultDescription
autoresizebooleanfalseGrows the textarea vertically to fit its current value.

[appFieldItem]

Inputs

InputTypeDefaultDescription
valuestringrequiredIdentifies the item when deriving control and label IDs in a group.

Context, Providers, and Utilities

ExportAngular API
FieldRootProviderProvides an externally created field API through its required value input.
FieldsetRootProviderProvides an externally created fieldset API through value.
useField(options)Creates the signal-backed field API inside an Angular injection context.
useFieldset(options)Creates the signal-backed fieldset API inside an Angular injection context.
injectFieldContext()Injects the nearest field context.
injectFieldContextOptional()Injects the nearest field context when one exists.
injectFieldsetContext()Injects the nearest fieldset context.
injectFieldsetContextOptional()Injects the nearest fieldset context when one exists.
FieldImportsReadonly collection containing the field UI and context providers.

Types

ExportDescription
FieldElementIdsOptional overrides for generated field part IDs.
FieldResolvedIdsFully resolved identifiers used by a field instance.
UseFieldPropsConfiguration accepted by useField.
UseFieldOptionsAngular context options passed to useField.
UseFieldReturnSignal-backed field state, prop getters, and registration APIs.
FieldsetResolvedIdsFully resolved identifiers used by a fieldset instance.
UseFieldsetPropsConfiguration accepted by useFieldset.
UseFieldsetOptionsAngular context options passed to useFieldset.
UseFieldsetReturnSignal-backed fieldset state and prop getters.