The Toggle component acts as a way to allow the User to switch between two mutually exclusive options. While it technically mirrors a Checkbox state, its effect on the system is immediate—much like a light switch immediately turns on or off the lights. In contrast, the checked state of a Checkbox won't be applied until a separate action to confirm the selection is taken.
indeterminate Toggle convey a "mixed" state that neither qualifies as toggled or not toggled. An example use case is when a Toggle acts as a "parent" of a collection of child Toggle components:
indeterminate: children are a mix of toggled and not toggled.<dt-stack as="fieldset" gap="100"> <dt-toggle class="d-g-200">Unchecked Toggle</dt-toggle> <dt-toggle :model-value="true" class="d-g-200">Checked Toggle</dt-toggle> <dt-toggle disabled class="d-g-200">Unchecked Disabled</dt-toggle> <dt-toggle :model-value="true" disabled class="d-g-200">Checked Disabled</dt-toggle> <dt-toggle :model-value="'mixed'" class="d-g-200">Indeterminate Toggle</dt-toggle> <dt-toggle :model-value="'mixed'" class="d-g-200" disabled>Indeterminate Disabled</dt-toggle> <dt-toggle class="d-g-200" :show-icon="false">Without icon</dt-toggle> </dt-stack>
<dt-stack as="fieldset" gap="100"> <dt-toggle :size="200" class="d-g-200">Small size</dt-toggle> <dt-toggle class="d-g-200">Default size</dt-toggle> </dt-stack>
<dt-toggle v-model="checked" class="d-g-200">Toggle</dt-toggle>
This component uses a native button element under the hood that has a role switch and type button to improve accessibility.
See W3C guidelines
for more information.
The best accessibility is semantic HTML. Most screen readers understand how to parse buttons if they're correctly formatted. When it comes to toggles, there are a few things to keep in mind:
id attribute.for attribute. This correlates with the toggle's id.fieldset to group them and a legend to title the group. For further information, please visit Gov.UK's article, "Using the fieldset and legend elements".The button element should be fully accessible by keyboard. To accomplish this, the DtToggle component automatically
populates several ARIA attributes to the underlying button element depending on the checked and
disabled states. However, if a label default slot is not used with DtToggle
(without including an aria-label), a console warning error will be thrown indicating that this issue exists.
The button element should capture keyboard focus as long as it is not disabled (disabled prop is true).
ENTER key will
emit an update:modelValue event with the current value of the toggle and will change its internal checked state.
import { DtToggle } from '@dialpad/dialtone-vue';
Name
|
Type
|
|---|---|
default | Slot for the main content |
Name
|
Default
|
Type
|
|---|---|---|
disabled | false |
"true"
|
"false"
Disables the toggle interactions |
id | generated unique ID | string The id of the toggle |
labelChildProps | {} | object A set of props that are passed into the label container |
labelClass | '' | string|array|object Used to customize the label container |
modelValue | false |
"true"
|
"false"
|
"'mixed'"
Value of the toggle |
showIcon | true |
"true"
|
"false"
Shows the icon |
showLabel | true |
"true"
|
"false"
Determines visibility of toggle label. |
size | 300 |
"200"
|
"300"
The size of the toggle. |
toggleOnClick | true |
"true"
|
"false"
Whether the component toggles on click. If you set this to false it means you will handle the toggling manually
via the checked prop or v-model. Change events will still be triggered. |
Name
|
Type
|
|---|---|
update:modelValue | Boolean Event fired to sync the modelValue prop with the parent component |
Class
|
Applies to
|
Description
|
|---|
Toggle documentation last updated Friday, September 4, 2026
fix/popover-modal-zindex-scope