Form Field Types

Radio

The radio type is a controlled component provided by radix-ui. Using the choices property, you can pass a single array of string values or { value, label, disabled? } values. It is similar to the select option, however all the choices are displayed in a list.

// note, this is an element in the fields array (see getting started) { type: 'radio', name: 'dinner-choice', label: 'Dinner choice', helpText: 'Note, the vegetarian option is vegan.', choices:[ { label: 'Chicken', value: 'chicken' }, { label: 'Fish', value: 'fish' }, 'Vegetarian', ] } // ... rest of the fields array

Demo

Note, the vegetarian option is vegan.

Properties

The following documents the full list of properties that alter a text field's behavior.

PropertyTypeDescription
nameStringThe form data/state object property name.
labelStringThe label for the form field. This is typically displayed next to the field to describe what it is for.
defaultStringThe default value for the form field. This is used to pre-populate the field with a value when the form is first loaded.
choicesRDFChoiceOption[]An array of string or `{ value: string, label: string, disabled?: boolean }. Note that a combination of types may be used if desired.
helpTextStringAdditional text that can be displayed below the form field to provide additional information or instructions for the user.
HelpTextReactElementTo render markup, tooltips and other more advanced help options, a component can be returned from this property.
observeBooleanDetermines if the field will be included in stateful updates that can be passed both during validation and changes to form state. See advanced topics for more detail
disabledBooleanDetermines whether the form field should be disabled. Values and any state prior to being disabled is preserved.
hiddenBooleanDetermines whether the form field should be hidden. Note, that this is done with CSS. The markup will still be rendered as to avoid unnecessary re-renders and destruction of controlled input state.
optionsRegisterOptionsObject you would pass if you were using react-hook-form directly. RDF calls register automatically and passes this configuration as the second argument.