Skip to content

toggleChange

toggleChange is a DOM event that occurs whenever the active toggle button changes in a group.

Event body

The toggleChange body has a ISingleToggleOnModeToggleChange type which represents the details of a currently active toggle button in a group. It is optional so it might not exist.

Example

In this example we listen to toggleChange event and perform an action whenever it's emitted.

useStorefront(async (storefront) => {
    document.addEventListener('toggleChange', ({ detail }) => {
        console.log('Newly active toggle button has a value of: ', detail.value);
    });
});