Introducing Attractive.js: A JavaScript-Free Library for HTML Attributes

Announcing Attractive.js, a new JavaScript-free JavaScript library This article was originally published on Rails Designer After last week's introduction of Perron, I am now announcing another little “OSS present”: a JavaScript-free JavaScript library. 🎁 Say what? 👉 If you want to check out the repo and star ⭐ it, that would make my day! 😊 Attractive.js lets you add interactivity to your site using only HTML attributes (hence the name attribute active). No JavaScript code required. Just add ⁠data-action and, optionally, data-target attributes to your elements, and… done! Something like this: <button data-action="addClass#bg-black" data-target="#door"> Paint it black </button> <p id="door"> Paint me black </p> Or if you want to toggle a CSS class, you write: data-action="toggleClass#bg-black". Or toggle multiple CSS classes: data-action="toggleClass#bg-black,text-white". Other actions include addAttribute, form#submit and copy#my-api-key. Attractive, right? 😅 I designed Attractive.js to be a little sister of Stimulus, hence the similar data-* https://lnkd.in/gifb59x9

To view or add a comment, sign in

Explore content categories