--- name: alpine-js description: Adds reactive and declarative behavior to HTML with minimal JavaScript using Alpine.js directives. Use when adding lightweight interactivity to server-rendered pages, building interactive components without a build step, or when user mentions Alpine.js, x-data, or Tailwind-style reactivity. --- # Alpine.js Lightweight JavaScript framework for adding reactive behavior directly in HTML markup. ## Quick Start ```html
``` ## Core Directives ### x-data ```html
``` ### x-bind ```html
Styled text
``` ### x-on ```html Link
Press Ctrl+S to save
Click outside to close
Listen to window scroll
Throttled submit
Clicking here won't trigger closeModal
Capture phase
Passive scroll
``` ### x-text & x-html ```html
``` ### x-model ```html

Hello, !

Preview
``` ### x-show & x-if ```html
Visible when isVisible is true
Fades in/out
Animated panel
``` ### x-for ```html ``` ### x-init ```html
Loading...
``` ### x-effect ```html

``` ### x-ref ```html
``` ### x-cloak ```html
``` ### x-ignore ```html

``` ## Magic Properties ### $el ```html
Log width on init
``` ### $refs ```html
``` ### $store ```html
``` ### $watch ```html
``` ### $dispatch ```html
Listens to window events
``` ### $nextTick ```html
``` ### $root ```html
``` ### $data ```html
``` ### $id ```html
``` ## Complete Examples ### Dropdown Menu ```html
Profile Settings Logout
``` ### Modal ```html

Modal Title

Modal content here...

``` ### Tabs ```html
Content for Tab 1
Content for Tab 2
Content for Tab 3
``` ### Fetch Data ```html
``` ## Reference Files - [plugins.md](references/plugins.md) - Alpine.js plugins (Mask, Intersect, Persist, etc.) - [patterns.md](references/patterns.md) - Common patterns and best practices