menu_book Course Curriculum (Alpine.js) expand_more
Core State
Binding
Events
Visibility
Lists & Templates
Magic Properties
Plugins & Extensibility
Reusable data with Alpine.data
Learn Reusable data with Alpine.data in Alpine.js with a dedicated explanation, topic-specific example, edge guidance, and mastery check.
12 min read
•
Beginner
Advertisement
alpinejs-004.html
html
<script>Alpine.data("dropdown",()=>({open:false,toggle(){this.open=!this.open}}))</script><div x-data="dropdown"><button @click="toggle">Menu</button></div>
What to watch
Content source & attribution
Original Syntaxis Content · Original Syntaxis Content