Skip to main content
🏠FormToggle SwitchVersion: 2.0.0-beta.5

Toggle Switch

Thales Design System global CSS styles library - Toggle Switch Notice

Size

You can change size attribute between small, medium and large. By default, the size is on medium

SmallMidLarge
<QtmToggleSwitch size="small">Small</QtmToggleSwitch>
<QtmToggleSwitch size="medium">Mid</QtmToggleSwitch>
<QtmToggleSwitch size="large">Large</QtmToggleSwitch>

Colors

The toggle switch are available in two colors neutral and primary. The default color of a checked toggle switch is the primary color.

Default color

Primary color

Neutral color

<QtmToggleSwitch checked>Default color</QtmToggleSwitch>
<QtmToggleSwitch checked color="primary">Primary color</QtmToggleSwitch>
<QtmToggleSwitch checked color="neutral">Neutral color</QtmToggleSwitch>

Disabled switch

Add disabled to the toggle switch to disable this element.

Label
<QtmToggleSwitch disabled>Label</QtmToggleSwitch>

Label on the right

You may want to set the toggle switch on the right. For that, you have to set labelPosition attribute to right. By default, the toggle switch has labelPosition="left"

defaultleftright
<QtmToggleSwitch>default</QtmToggleSwitch>
<QtmToggleSwitch labelPosition="left">left</QtmToggleSwitch>
<QtmToggleSwitch labelPosition="right">right</QtmToggleSwitch>

An icon in the switch

You have the possibility to display icon in the switch. For that, you have to add displayIcon attribute to your toggle switch

Label

Label

Label

<QtmToggleSwitch size="small" displayIcon>Label</QtmToggleSwitch>
<QtmToggleSwitch displayIcon>Label</QtmToggleSwitch>
<QtmToggleSwitch size="large" displayIcon>Label</QtmToggleSwitch>

By default, icons are a cross and a thickle. You can change that by adding properties below:

  • iconOn with a name of the icon when the switch is toggle "on"
  • iconOff with a name of the icon when the switch is toggle "off"

We are using the icon of material design for now. To know the name of the icon, please go to the material icon website here

Label

Label

<QtmToggleSwitch color="primary" displayIcon iconOn="lock_open" iconOff="lock">Label<QtmToggleSwitch>
<QtmToggleSwitch color="neutral" displayIcon iconOn="face" iconOff="group">Label<QtmToggleSwitch>

Checked

You can control a toggle switch by using checked attribute.

Primary

Neutral

<QtmToggleSwitch checked color="primary">Primary</QtmToggleSwitch>
<QtmToggleSwitch checked color="neutral">Neutral</QtmToggleSwitch>

API

QtmToggleSwitch

PropertyTypeDefaultDescription
checkedbooleanfalseIf true, the toggle is checked.
classesstring''list of classes to override or extend the styles applied to the component. You can use available utility classes by importing
color"neutral" | "primary"'primary'The color of the toggle switch
defaultCheckedbooleanfalseIf true, the component is checked by default.
disabledbooleanfalseIf true, the component is disabled.
displayIconbooleanfalseIf we want the icon displayed on the toggle
iconOffstringThe icon on the left side when toggle is switched off. You can find the icon name on material icon. You have to set the icon displayed
iconOnstringThe icon on the right side when toggle is switched on. You can find the icon name on material icon. You have to set the icon displayed
inputIdstringinput id of the toggle switch
labelPosition"" | "left" | "right"''The position of the label
namestringName of the toggle switch
size"large" | "medium" | "small"'medium'The size of the toggle switch
EventTypeDescription
onValueChangedCustomEvent<ToggleSwitchDetail>Callback fired when the value is changed through the user interface. You can pull out the new value by accessing event.detail