d3-fc-switcher

html class switcher (toggling class)

Usage no npm install needed!

<script type="module">
  import d3FcSwitcher from 'https://cdn.skypack.dev/d3-fc-switcher';
</script>

README

D3-FC switcher

Lightweight implementation of html class switcher (toggling class)

Useful for fast prototyping, when you need fast toggle classes on dom elements

Demo

Try it out ->

Interface

Install

  • npm: npm install d3-fc-switcher
  • yarn: yarn add d3-fc-switcher

Usage

In your main js file

import { Switcher } from 'd3-fc-switcher'

Switcher.makeDefault()

Then you can use in your html template

<div data-switchable="switchable1" data-switchable-class="active"></div>

<button data-switcher="switchable1">switcher</button>

When button is clicked script will add '.active' class to your switchable div. When button is clicked second time script will remove '.active' from div