Skip to content

Field types

Built-in fields synchronize values with the surrounding form and display its validation messages. Import them from @cratis/arc.react/commands and render them inside CommandForm.

Use an explicit command type for fields created by asCommandFormField. This field fragment assumes imports for InputTextField and your generated UpdateProfile class with a string name property:

<InputTextField<UpdateProfile> value={c => c.name} title="Name" />

Omitting both the generic and an accessor parameter annotation leaves c as unknown. The generic checks property names; most field accessors return unknown, so it does not guarantee the selected property’s value type matches the control. Use simple property accessors, not computed or nested expressions.

Radio fields infer the selected value type from the accessor itself. This field fragment expects a generated UserSettingsCommand whose role accepts 'reader' or 'admin':

<RadioGroupField
value={(c: UserSettingsCommand) => c.role}
title="Role"
options={[
{ value: 'reader', label: 'Reader' },
{ value: 'admin', label: 'Administrator' }
]}
/>
PropTypeContract
valueProperty accessorRequired; selects the command property.
titlestringField title shown by the default title renderer.
requiredbooleanOverrides the control’s inferred required flag, not the command’s validation rules.
iconReact.ReactElementOptional icon decoration.
descriptionstringOptional description/tooltip decoration.
className, stylestring, React.CSSPropertiesControl or wrapper styling, depending on field type.
currentValueunknown (typed for radios)Explicit field seed; undefined supplies nothing. Binding supplies the live value internally.
initialValue, noInitialValue, populationKeyPopulation metadataSee Data loading.

Fields default to required when their generated PropertyDescriptor.isOptional is false (and also when no descriptor is resolved). This sets an input attribute. CommandForm has noValidate, so it does not enforce browser required/type/range constraints on submit. Payload presence validation checks null/undefined, not empty strings or false booleans. Use explicit command validation rules.

onValueChange, onBlur, descriptor, and field-name props participate in internal binding. Custom adapters must forward the injected blur handler. Do not attach a public onBlur and assume it overrides or composes with the form’s injected validation callback; use the form’s interaction callbacks or an adapter that preserves forwarding.

  • Edits update the command through the form setter and advance its revision.
  • Silent validation updates form validity; validateOn controls when displayed errors are refreshed.
  • Most controls add an invalid border; RangeField currently does not vary its border with invalid state, though the form still displays its message.
  • Display defaults do not seed payload values. Define intentional initial values on the form.
FieldValue and control
InputTextFieldStrings; text, email, password, date/time text, color, URL, telephone, and search.
NumberFieldNumbers; empty/invalid native text input converts to zero.
TextAreaFieldMulti-line strings.
CheckboxFieldBoolean checked state.
RadioButtonFieldOne typed option for a property.
RadioGroupFieldA list of typed options for a property.
RangeFieldNumeric slider with value display.
SelectFieldString values from a native select; option IDs are stringified.

Most fields use full-width inline layout, 0.75rem padding, and 0.375rem rounded borders. Theme colors use CSS variables with some fallbacks; application CSS must define any variables or utility classes you rely on. There is no automatic UI-library installation or comprehensive accessible label/error association. For explicit control IDs, ARIA props, or unsupported native attributes, use custom fields.