Socket
Book a DemoInstallSign in
Socket

makeup-switch

Package Overview
Dependencies
Maintainers
0
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

makeup-switch

A JavaScript class representing an ARIA switch

latest
Source
npmnpm
Version
0.3.7
Version published
Maintainers
0
Created
Source

makeup-switch

A JavaScript class that represents an ARIA switch.

Available in CommonJS and ES Module format.

View Demo.

HTML

The following markup is required. Classnames are configurable (see config section below).

<span id="label1">switch 1</span>
<span class="switch">
  <span class="switch__control" role="switch" tabindex="0" aria-checked="false" aria-labelledby="label1"></span>
  <span class="switch__button"></span>
</span>

CSS

No CSS is provided. However, the class is fully compatible with eBay Skin.

JavaScript

// Consuming as CommonJS (note use of 'default()')
// const MakeupSwitch = require('makeup-switch').default();

// Consuming as ESM (recommended)
import MakeupSwitch from "makeup-switch";

document.querySelectorAll(".switch").forEach(function (el, i) {
  const widget = new MakeupSwitch(el, config);

  el.addEventListener("makeup-switch-toggle", function (e) {
    console.log(e.type, e.detail);
  });
});

Config

The constructor takes a configuration object as its second parameter.

customElementMode (deprecated)

Set to true if using the class as the model for a custom element (aka Web Component)

BEM

Use this object to specify your custom classnames (i.e. if you don't wish to use the default switch prefixes).

  • bem.control: classname for the focusable element (default: switch__control)

Events

makeup-switch-toggle

Fired when the switch is toggled.

  • detail.on: true or false

FAQs

Package last updated on 19 Aug 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts