Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/rah-emil/easy-toggler

Simple class switcher on web elements. JavaScript only.
https://github.com/rah-emil/easy-toggler

class dropdown easy-toggle easy-toggler js-lib tabs toggle toggle-class toggle-class-javascript toggle-switches

Last synced: about 2 months ago
JSON representation

Simple class switcher on web elements. JavaScript only.

Awesome Lists containing this project

README

        

# EasyToggler.js 🔗🚀
![npm bundle size](https://img.shields.io/bundlephobia/min/easy-toggler)
![YouTube Channel Subscribers](https://img.shields.io/youtube/channel/subscribers/UCj5-dlnKYZ7O2HIYgP8urqw?style=flat)
[![](https://data.jsdelivr.com/v1/package/npm/easy-toggler/badge?style=rounded)](https://www.jsdelivr.com/package/npm/easy-toggler)
![npm](https://img.shields.io/npm/dm/easy-toggler)
![GitHub](https://img.shields.io/github/license/rah-emil/easy-toggler)
![GitHub issues](https://img.shields.io/github/issues/rah-emil/easy-toggler)

Simple class switcher on web elements. JavaScript only.

![](readme/mem.png)

## Use a plugin instead of JavaScript
```html

Toggle class

Add class

Remove class

Removing a class if we click on an empty space
```

## Import EasyToggler
### ES
```html

import easySetup from "easy-toggler";

easySetup({
// html attrs
toggle: 'easy-toggle',
add: 'easy-add',
remove: 'easy-remove',
class: 'easy-class',
rcoe: 'easy-rcoe',
parallel: 'easy-parallel',
self: 'easy-self',
selfRcoe: 'easy-self-rcoe',

// Hooks
onToggle($el){},
onAdd($el){},
onRemove($el){},
onRcoe($el){},
});

```
or easier:
```html

import easySetup from "easy-toggler";
easySetup();

```

### CDN jsDelivr (iife)
```html

```
### CJS
```html

const easySetup = require("easy-toggler");

easySetup({
// html attrs
toggle: 'easy-toggle',
add: 'easy-add',
remove: 'easy-remove',
class: 'easy-class',
rcoe: 'easy-rcoe',
parallel: 'easy-parallel',
self: 'easy-self',
selfRcoe: 'easy-self-rcoe',

// Hooks
onToggle($el){},
onAdd($el){},
onRemove($el){},
onRcoe($el){},
});

```
or easier:
```html

const easySetup = require("easy-toggler");
easySetup();

```

## Demo
Visit demo page: [rah-emil.ru/easy-toggler](https://rah-emil.ru/easy-toggler)

### Example â„–1
When you click the button, the class ```show``` will be added to ``````
```html
Menu

```

### Example â„–2
When you click the button, the class ```open``` will be added to ```