Skip to content

clicked

clicked is a DOM event that occurs whenever the toggle button is clicked.

Event body

The clicked body has a ITargetToggleButton type which represents the details of a toggle button that dispatched the event. It is optional so it might not exist.

Example

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

useStorefront(async (storefront) => {
    document.addEventListener('clicked', ({ detail }) => {
        console.log(detail.target, ' has been clicked');
    });
});