Toggle Button Component

1. Overview

The TOGGLE_BUTTON component provides a group of toggle buttons where users can select exactly one option from multiple choices.

🛝 Use the Dynamic Form Playground to see the Toggle Button component in action and try out different configurations

2. Key Features

  • Single selection from multiple options
  • Static or dynamic option fetching
  • Translation and string interpolation support

3. Configuration Properties

Base Properties

PropertyTypeRequiredDescription
type'TOGGLE_BUTTON'YesSpecifies the field type as TOGGLE_BUTTON.
idstringYesUnique identifier for the field. The field's value is stored in the form state under this key.
renderNamestringNoOptional name added as data-render-name attribute to locate the rendered element in the DOM.
labelstringNoLabel text displayed above the options. Supports translation and string interpolation.
valuestring | number | booleanNoThe field's initial value. If set, the corresponding option will be pre-selected.
notestringNoInformational note displayed when there are no errors.
infoIconDfInfoIconConfigNoInfo icon with popover. Object with popoverText (string, required) and popoverDirection ('top', 'bottom', 'left', 'right').
validatorsarrayNoValidation rules for the field. Common type: REQUIRED. Each validator has type and optional errorMessage.
testIdstringNoTest identifier for automated testing. Set as data-testid attribute.
aclarrayNoAccess control rules for field visibility/editability. Each rule has state ('hidden', 'readonly', 'disabled', 'visible', 'editable') and optional condition (Filtrex expression).
spacingstringNoMargin spacing before the next field: 'NONE' (0px), 'XS' (8px), 'S' (16px), 'M' (24px), 'L' (32px), 'XL' (40px), 'XXL' (48px).

Note: This component does not support the hint property, unlike most other interactive components. The columnSpan property is also not supported, meaning the component always spans the full width of the form (12 columns).

Component Specific Properties

PropertyTypeRequiredDescription
optionsDfOptions[] | stringYesThe options property can take one of two forms:
1. It can be a hardcoded array of objects for direct display in a toggle button. Each object must have a label to display and a corresponding value.
2. A string that represents an expression. This expression is used by an option provider service to dynamically fetch the toggle button options.
See also DfOptions
sizestringNoTo set the size of the toggle button ('small' or 'large'). The default size is 'large'. In Expert journeys only 'small' size is allowed.

Options Properties (DfOptions)

PropertyTypeRequiredDescription
labelstringYesThe label to display for the list
valuestring | number | booleanYesThe value of the option
testIdstringNoThe test id of the option used for automated tools, like cypress to find the component
and made independent of other config changes.
If implemented, the value should be the following data-testid=VALUE_HERE
with the testid in lowercase.

4. Configuration Examples

Basic Toggle Button

Example :
{
  "id": "insuranceType",
  "type": "TOGGLE_BUTTON",
  "label": "Select Insurance Type",
  "options": [
    {
      "label": "Life Insurance",
      "value": "life"
    },
    {
      "label": "Health Insurance",
      "value": "health"
    },
    {
      "label": "Vehicle Insurance",
      "value": "vehicle"
    }
  ],
  "validators": [
    {
      "type": "REQUIRED"
    }
  ]
}

Dynamic Toggle Button with Expression

Example :
{
  "id": "insurancePlan",
  "type": "TOGGLE_BUTTON",
  "label": "Select Insurance Plan",
  "size": "small",
  "options": "$.availableInsurancePlans",
  "validators": [
    {
      "type": "REQUIRED",
      "errorMessage": "Please select an insurance plan"
    }
  ]
}

5. API Reference

For complete API documentation, see DfToggleButtonConfig.

For Aquila component documentation and design guidelines, see Toggle Button - Aquila Design System.

results matching ""

    No results matching ""