Switcher Component

1. Overview

The SWITCHER component provides a toggle switch for binary on/off choices.

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

2. Key Features

  • Binary toggle for on/off states
  • Configurable label positioning (left or right)
  • Size variants (small or large)
  • Translation and string interpolation support
  • Form validation support
  • Default value support

3. Configuration Properties

Base Properties

PropertyTypeRequiredDescription
type'SWITCHER'YesSpecifies the field type as SWITCHER.
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.
labelstringYesLabel text displayed next to the switcher. Supports translation and string interpolation.
valuebooleanNoInitial state of the switcher (true = on, false = off). Set via standard form value mechanism.
notestringNoInformational note displayed when there are no errors.
hintstringNoHelper text displayed below the field.
infoIconDfInfoIconConfigNoInfo icon with popover. Object with popoverText (string, required) and popoverDirection ('top', 'bottom', 'left', 'right').
validatorsarrayNoValidation rules for the field. Common type: REQUIRED_TRUE. 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).
columnSpannumberNoNumber of columns to span (1-12) in CUSTOM_COLUMN layout. Default: 12 (full width). See Overriding the number of grid columns when using --df-custom-columns.
spacingstringNoMargin spacing before next field: 'NONE' (0px), 'XS' (8px), 'S' (16px), 'M' (24px), 'L' (32px), 'XL' (40px), 'XXL' (48px).

Component Specific Properties

PropertyTypeRequiredDescription
labelPositionstringNoSets the label position to be on the left or right. Default is left.
sizestringNoSets the switcher size to be small or large. Default is small.

4. Configuration Examples

Basic Switcher

Example :
{
  "id": "marketingConsent",
  "type": "SWITCHER",
  "label": "I want to receive marketing communications"
}

Required Switcher with Validation

Important: For consent scenarios, use REQUIRED_TRUE validator to ensure the switcher is enabled/turned on.

Example :
{
  "id": "dataProcessingConsent",
  "type": "SWITCHER",
  "label": "I consent to data processing",
  "validators": [
    {
      "type": "REQUIRED_TRUE",
      "errorMessage": "Consent is required to proceed"
    }
  ]
}

Switcher with Custom Size and Label Position

Example :
{
  "id": "autoRenewal",
  "type": "SWITCHER",
  "label": "Automatic policy renewal",
  "size": "large",
  "labelPosition": "right",
  "value": true,
  "hint": "Your policy will automatically renew each year"
}

5. API Reference

For complete API documentation, see DfSwitcherConfig.

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

results matching ""

    No results matching ""