Skip to content

RadioButtonField

A single radio input for assigning a specific value to a command property.

RadioButtonField infers the allowed setValue type from the bound accessor. That keeps each radio option aligned with the command property it updates.

PropTypeDefaultDescription
value(instance: TCommand) => TValueRequired. Accessor function returning the property value from the command instance.
setValueTValueRequired. Value assigned when the radio button is selected. The type is inferred from value.
labelReact.ReactNodeContent displayed next to the radio button.
titlestringThe label for the field (shown when showTitles is enabled).
requiredbooleanOverride automatic required detection.
disabledbooleanfalseDisables the radio button.

Selection assigns setValue directly, and checked state uses Object.is. Prefer primitive option values; freshly constructed objects do not compare structurally. Radios sharing a bound property use its field name for grouping. See Common props; required is a control flag, not a replacement for command validation.

These illustrative field fragments require RadioButtonField from @cratis/arc.react/commands and a generated NotificationPreferences whose contactMethod accepts 'email' and 'sms'. Place both inside its CommandForm. Annotating the accessor parameter enables option type inference; do not pass the command type as this component’s accessor generic.

<RadioButtonField
value={(c: NotificationPreferences) => c.contactMethod}
setValue="email"
label="Email"
title="Preferred Contact Method"
/>
<RadioButtonField
value={(c: NotificationPreferences) => c.contactMethod}
setValue="sms"
label="SMS"
/>