Alpine.js is "Tailwind for JavaScript." Reactive behavior directly in HTML markup. 17KB, no build step, perfect companion to htmx or server-rendered pages. Quick Start <script defer src= "https://cdn.jsdelivr.net/npm/alpinejs@3/dist/cdn.min.js" ></script> <div x-data= "{ open: false }" > <button @ click= "open = !open" > Toggle </button> <div x-show= "open" x-transition > Hello! I'm visible now. </div> </div> Key Directives <!-- Reactive data --> <div x-data= "{ count: 0 }" > <button @ click= "count++" > Count: <span x-text= "count" ></span></button> </div> <!-- Conditional rendering --> <div x-data= "{ tab: 'home' }" > <button @ click= "tab = 'home'" > Home </button> <button @ click= "tab = 'about'" > About </button> <div x-show= "tab === 'home'" > Home content </div> <div x-show= "tab === 'about'" > About content </div> </div> <!-- Loops --> <ul x-data= "{ items: ['Apple', 'Banana', 'Cherry'] }" > <template x-for= "item in items" > <li x-text= "item" ></li> </template> </ul> <!-- Two

Continue reading on Dev.to Webdev

Opens in a new tab

Read Full Article
2 views

Related Articles

How-To

Circulation Metrics Framework for Living Systems

Medium Programming6h ago

Red Rooms makes online poker as thrilling as its serial killer
How-To

Red Rooms makes online poker as thrilling as its serial killer

The Verge9h ago

Don’t Know What Project to Build? Here Are Developer Projects That Actually Make You Better
How-To

Don’t Know What Project to Build? Here Are Developer Projects That Actually Make You Better

Medium Programming10h ago

Why Most Developers
Stay Broke
How-To

Why Most Developers Stay Broke

Medium Programming12h ago

Building a Simple Lab Result Agent in .NET (Microsoft Agent Framework + Ollama)
How-To

Building a Simple Lab Result Agent in .NET (Microsoft Agent Framework + Ollama)

Medium Programming13h ago

Discover More Articles