Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

egghead.io

Sprinkle declarative, reactive behaviour on your HTML with Alpine JS

via egghead.io

Overview

Welcome to this beginner level series on Alpine JS!
Alpine JS is a rugged, minimal framework for composing JavaScript behaviour in your markup. It brings declarative, reactive, data-driven nature of libraries like React or Vue to your HTML templates.
In this series, you will learn about Alpine's handy directives. You'll discover how to define a component scope with x-data, run code on mount with x-init, attach event listeners with x-on, display data with x-text, decide wether or not to show an element with x-show, iterate through data with x-for, retrieve a DOM element with x-ref, learn how to achieve two-way data binding with x-model, and much more.
You'll also learn how "modifiers" can be applied and chained to directives to provide additional functionality: control the animation transition of entering and leaving DOM elements, debounce an event listener, etc.
We'll also touch on what Alpine calls "magic properties", which give you access to native browser events ($event), reference to DOM elements ($refs), and more.
You'll gradually discover Alpine's API and syntax, from building simple tabs to a mini app that fetches a dog picture based on a "breed" search field.
Get ready to breathe some fresh air - it's time to walk into cool, green Alpine pastures!

Syllabus

  • Series Intro - Beginner Level Alpine JS
  • Update a count state value with the x-on event listener directive in Alpine JS
  • Toggle visibility and styles based on state with `x-show` and `x-bind` in Alpine JS
  • Iterate through data with the `x-for` attribute in Alpine JS
  • Control enter and leave transitions with the `x-show.transition` modifier in Alpine JS
  • Keep a DOM input and state value in sync with the `x-model` directive in Alpine JS
  • Focus an input field on button click with `x-ref` and the `$refs` property in Alpine JS
  • Focus in input field on page load with `x-init` in Alpine JS
  • Refetch API data when a state value changes with the `$watch` property in Alpine JS

Taught by

Simon Vrachliotis

Reviews

4.7 rating at egghead.io based on 16 ratings

Start your review of Sprinkle declarative, reactive behaviour on your HTML with Alpine JS

Never Stop Learning.

Get personalized course recommendations, track subjects and courses with reminders, and more.

Someone learning on their laptop while sitting on the floor.