Newsletter
Join the Community
Subscribe to our newsletter for the latest news and updates
A tiny JavaScript library to easily toggle the state of any HTML element in any contexts, and create UI components in no time.
Easy Toggle State is a tiny JavaScript library for toggling the state of HTML elements with CSS classes, letting you build dropdowns, tooltips, tabs, and other UI components using only HTML attributes and your own CSS.
Easy Toggle State is a tiny JavaScript library that toggles a CSS class on a trigger element and any number of associated target elements, enabling UI components like dropdowns, navigation buttons, tooltips, collapsible panels, lightboxes, tabs, and switches. It runs entirely in the browser and requires no framework — you add a single script and then control behavior with HTML attributes. The library is created by Matthieu Bué and released under the MIT License.
npm install easy-toggle-state), link from cdnjs, or download the minified file directly from the GitHub repository.Install the script via npm install easy-toggle-state, link from cdnjs, or download the minified file directly. Then add the appropriate HTML attributes to your trigger and target elements — the library listens for the defined events and toggles the CSS class on the trigger and targets. The documentation at twikito.github.io/easy-toggle-state/ includes examples and a full attribute reference.
Yes, Easy Toggle State is open source and released under the MIT License, so you can use it freely in personal and commercial projects.
No. Easy Toggle State is vanilla JavaScript and works directly on the DOM, so it can be used in plain HTML pages or alongside any framework.
You can install it with npm (npm install easy-toggle-state), link it from cdnjs, or download the minified file directly from the GitHub repository. Both ES5 and ES6 builds are available in the dist folder.
Common examples shown in the documentation include dropdowns, navigation buttons, tooltips, collapsible panels, lightboxes, tabs, and switches. The pattern works for any component that involves toggling a class on one or more elements.
