Skip to content

D3-FC/switcher

Repository files navigation

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