# Alpine.js ![npm bundle size](https://img.shields.io/bundlephobia/minzip/alpinejs) ![npm version](https://img.shields.io/npm/v/alpinejs) [![Chat](https://img.shields.io/badge/chat-on%20discord-7289da.svg?sanitize=true)](https://alpinejs.codewithhugo.com/chat/) Alpine.js offers you the reactive and declarative nature of big frameworks like Vue or React at a much lower cost. You get to keep your DOM, and sprinkle in behavior as you see fit. Think of it like [Tailwind](https://tailwindcss.com/) for JavaScript. > Note: This tool's syntax is almost entirely borrowed from [Vue](https://vuejs.org/) (and by extension [Angular](https://angularjs.org/)). I am forever grateful for the gift they are to the web. ## Translated documentation | Language | Link for documentation | | --- | --- | | Arabic | [**التوثيق باللغة العربية**](./README.ar.md) | | Chinese Simplified | [**简体中文文档**](./README.zh-CN.md) | | Chinese Traditional | [**繁體中文說明文件**](./README.zh-TW.md) | | German | [**Dokumentation in Deutsch**](./README.de.md) | | Indonesian | [**Dokumentasi Bahasa Indonesia**](./README.id.md) | | Japanese | [**日本語ドキュメント**](./README.ja.md) | | Portuguese | [**Documentação em Português**](./README.pt.md) | | Russian | [**Документация на русском**](./README.ru.md) | | Spanish | [**Documentación en Español**](./README.es.md) | | Turkish | [**Türkçe Dokümantasyon**](./README.tr.md) | | Français | [**Documentation en Français**](./README.fr.md) | | Korean | [**한국어 문서**](./README.ko.md) | ## Install **From CDN:** Add the following script to the end of your `` section. ```html ``` That's it. It will initialize itself. For production environments, it's recommended to pin a specific version number in the link to avoid unexpected breakage from newer versions. For example, to use version `2.8.2` (latest): ```html ``` **From npm:** Install the package from npm. ```js npm i alpinejs ``` Include it in your script. ```js import 'alpinejs' ``` **For IE11 support** Use the following scripts instead. ```html ``` The pattern above is the [module/nomodule pattern](https://philipwalton.com/articles/deploying-es2015-code-in-production-today/) that will result in the modern bundle automatically loaded on modern browsers, and the IE11 bundle loaded automatically on IE11 and other legacy browsers. ## Use *Dropdown/Modal* ```html
``` *Tabs* ```html
Tab Foo
Tab Bar
``` You can even use it for non-trivial things: *Pre-fetching a dropdown's HTML content on hover.* ```html
Loading Spinner...
``` ## Learn There are 14 directives available to you: | Directive | Description | | --- | --- | | [`x-data`](#x-data) | Declares a new component scope. | | [`x-init`](#x-init) | Runs an expression when a component is initialized. | | [`x-show`](#x-show) | Toggles `display: none;` on the element depending on expression (true or false). | | [`x-bind`](#x-bind) | Sets the value of an attribute to the result of a JS expression. | | [`x-on`](#x-on) | Attaches an event listener to the element. Executes JS expression when emitted. | | [`x-model`](#x-model) | Adds "two-way data binding" to an element. Keeps input element in sync with component data. | | [`x-text`](#x-text) | Works similarly to `x-bind`, but will update the `innerText` of an element. | | [`x-html`](#x-html) | Works similarly to `x-bind`, but will update the `innerHTML` of an element. | | [`x-ref`](#x-ref) | Convenient way to retrieve raw DOM elements out of your component. | | [`x-if`](#x-if) | Remove an element completely from the DOM. Needs to be used on a `