Alpine is a rugged, minimal tool for composing behavior directly in your markup. Think of it like jQuery for the modern web. Plop in a script tag and get going.


In order to install Alpine you have to run this command:

npm install alpinejs

Then in your Javascript file you have to initialize it:

import Alpine from 'alpinejs'

In order to learn Alpine and its basics their documentation is a great start. Below is a sample demo for a dropdown component:

<div x-data="{ open: false }">
<button @click="open = ! open">Toggle</button>
<div x-show="open" @click.outside="open = false">Contents...</div>

Also below is a search input:

search: '',
items: ['foo', 'bar', 'baz'],
get filteredItems() {
return this.items.filter(
i => i.startsWith(
<input x-model="search" placeholder="Search...">
<template x-for="item in filteredItems" :key="item">
<li x-text="item"></li>