Skip to content

CheckboxField

A checkbox input for boolean values. An undefined value displays as unchecked; clicking writes the control’s boolean checked state.

Prop Type Default Description
value (instance: TCommand) => unknown Required. Accessor function returning the property value from the command instance.
title string The label for the field (shown when showTitles is enabled).
label string Label text displayed next to the checkbox and associated with its input ID.
id string Generated by the form Override the checkbox input ID.
required boolean Override automatic required detection.

A required flag does not require this command property to be true: false is a present boolean and CommandForm uses noValidate. A consent checkbox needs an explicit backend rule requiring true. The adjacent label uses htmlFor to associate it with the checkbox, using the form-generated ID or your explicit id. See Common props for styling and population.

These illustrative field fragments require imports for CheckboxField from @cratis/arc.react/commands and your generated UserCommand with boolean agreeToTerms and newsletter properties. Place them inside that command’s form, initialized with intentional boolean defaults.

<CheckboxField<UserCommand>
value={c => c.agreeToTerms}
title="Terms of Service"
label="I agree to the terms and conditions"
/>
<CheckboxField<UserCommand>
value={c => c.newsletter}
title="Newsletter"
label="Send me newsletter updates"
/>