### Alpine.js HTML Setup Source: https://alpinejs.dev/start-here/index This snippet shows the basic HTML structure required to include Alpine.js from a CDN. It includes the necessary script tag in the head and a simple Alpine component in the body. ```html

``` -------------------------------- ### Alpine.js x-on Directive for Events Source: https://alpinejs.dev/start-here/index Shows how to use the x-on directive (or its shorthand '@') to listen for DOM events. This example listens for a 'click' event on a button and increments the 'count' state. ```html ``` -------------------------------- ### Alpine.js x-data Directive Source: https://alpinejs.dev/start-here/index Demonstrates the use of the x-data directive to declare reactive state within an Alpine.js component. The 'count' property is initialized to 0. ```html
``` -------------------------------- ### Build a Dropdown with Alpine.js Source: https://alpinejs.dev/start-here/index Demonstrates how to create a simple dropdown component using Alpine.js directives. It utilizes `x-data` to manage the dropdown's open/closed state and `x-show` to toggle its visibility. The `@click.outside` modifier provides a convenient way to close the dropdown when clicking outside of it. ```html
Contents...
``` -------------------------------- ### Looping Elements with x-for in Alpine.js Source: https://alpinejs.dev/start-here/index Illustrates how to loop through an array (filteredItems) using the x-for directive in Alpine.js. The directive is applied to a