Component Toggle
A toggle lets users switch between two opposing states, often used to turn a feature on or off.
Example
Props
Attr | Type | Default | Docs |
---|---|---|---|
checked | boolean | false | This boolean is used to set the toggle as "checked". |
disabled | boolean | false | This boolean is used to disable the toggle. |
hide-label | boolean | false | This property will visually hide the label. A label is still required to be provided for screenreader support. |
input-aria-label | string | null | This property can be used to set the ARIA label associated with this input (for screen readers). |
input-id | string | generateId('som-input') | This property can be used to specifically set an ID to the input field. If an ID is not provided, it will be dynamically generated. |
label | string | '' | This property can be used to set the inline label. |
label-class | string | '' | This property is a list of CSS classes that can be used to style the label. |
name | string | '' | This property is the form element name (used when submitting the form). |
size | "lg" | "sm" | 'sm' | This property determines the size of the toggle |
value | string | '' | This property is the toggle value sent on submit when using it in a form. |
Methods
Name | Returns | Docs |
---|---|---|
setFocus | Promise will resolve after focus. | This public method sets focus to the checkbox element. |
Events
Event | Detail | Docs |
---|---|---|
somBlur | any | This event is emitted when when the toggle loses focus. |
somChange | any | This event is emitted when the toggle value changes. |
somFocus | any | This event is emitted when when the toggle gets focus. |
Slots
Name | Docs |
---|---|
label | Label for the toggle. Alternatively, you can use the label attribute. |
Anatomy

- Toggle
- Toggle switch
- Label
Sizes
Labels
Use a label to clearly identify the toggle’s function. Toggles have a default label attribute, but custom labels can be used in some cases, such as user settings. If a toggle is used without a label, additional context like a card boundary or related content should support the toggle’s use.

The toggle’s default inline label appears to its right. Custom labels may be positioned differently or appear inside a container.
Avoid writing labels as questions or phrases like “Turn on” or “Turn off” — a toggle inherently represents an on or off state, so restating in the label is unnecessary and may confuse users as to what the toggle actually does.
How to use
When enabling a feature or functionality, the change should be immediate and obvious, such as toggling between dark and light mode. Toggles should never be used to answer a question or to agree to terms and conditions.
Toggle or checkbox?
When choosing between the two, remember:
- Checkboxes allow users to make any number of selections (many, one, or none), while toggles only turn a single binary option on or off.
- Unlike checkboxes, toggles reflect an immediate change.
- Checkboxes have error states; toggles do not.
Behavior
States
Toggles are either in an on or off state. For accessibility purposes, use ARIA labels and roles to describe the toggle and its current state.

Toggles are either on or off — there is no intermediary selection state.

A toggle’s appearance changes based on how the user is interacting with it.
- Default: The standard state of a toggle.
- Hover: When a user’s cursor moves over a toggle without clicking it.
- Focus: When a user highlights a toggle via the keyboard.
- Disabled: An unavailable action. Ensure that users aren’t confused as to why a toggle is disabled.
Interactions
Mouse
Clicking the toggle will change the state. Users can click on either the toggle or its label.
Keyboard focus
Users can focus on a toggle with the Tab key. The Spacebar will switch the toggle between its on and off states.
Layout
Toggles with related content may be organized together, but avoid arranging them horizontally.
Do you have an idea, or want to help us improve this page? Reach out to us via email.
DTMB-DG-Support@michigan.govNeed help? Visit our Support page to learn how to get assistance, troubleshoot issues, and connect with the team.