aura

Toggle

The Toggle component is a switch input. It behaves as a standard HTML checkbox input, but it is styled to match the design system. Per default they are rendered inlined, but can be stacked by wrapping them in a flex container or using a field.

Field Attributes

  • label (String): The label of the toggle.
  • label-start (String): The label of the toggle, rendered before the toggle.
  • description (String): The description of the toggle.
  • desc-start (String): The description of the toggle, rendered before the toggle.

Group Attributes

  • legend (String): The legend of the group.
  • divided (Boolean): Whether the toggle switches should be separated by a divider.
  • inline (Boolean): Whether the toggle switches should be rendered inline.

Basic Usage

toggle description

Copy to clipboard

<aura:toggle label="toggle" description="toggle description" />

Sizes

Copy to clipboard

<aura:toggle label="toggle" size="sm" />
<aura:toggle label="toggle" size="md" />
<aura:toggle label="toggle" size="lg" />

Alternative Label

toggle description

Copy to clipboard

<aura:toggle label-start="toggle" desc-start="toggle description" />

Disabled

Copy to clipboard

<aura:toggle disabled ... />

Checked

Copy to clipboard

<aura:toggle checked .../>

Grouped

To group toggle switches, wrap them in a aura:toggle.group component.

Default Group

Copy to clipboard

<aura:toggle.group legend="Default Group">
    <aura:toggle label="Toggle 1" />
    <aura:toggle label="Toggle 2" />
    <aura:toggle label="Toggle 3" />
</aura:toggle.group>

Group styles

When grouping toggle switches, you can use the inline attribute to render them inline. or divided to separate them with a divider.

Divided Group
Inline Group

Copy to clipboard

<aura:toggle.group divided>
    ...
</aura:toggle.group>

<aura:toggle.group inline>
    ...
</aura:toggle.group>