From jQuery to Alpine.js

Examples of what it looks like to simplify your JavaScript with Alpine.js

Real quick, what is Alpine.js?

Alpine.js is a minimal framework for composing JavaScript behavior in your markup. It offers a declarative syntax for defining behavior directly in your HTML, and it’s a great way to simplify your JavaScript code.

Starting simple

A mobile menu with a hamburger button

<div x-data="{ open: false }">
  <button @click="open = !open">Toggle Menu</button>
  <ul x-show="open">
	<!-- Your menu items here -->
  </ul>
</div>

Click the button to toggle the menu

A counter

Alpine’s x-data directive allows you to define the state you want to keep track of in your component.

<div x-data="{ count: 0 }">
    <button @click="count++">Click me</button>
 
    <span x-text="'Times clicked: ' + count"></span>
</div>

Easy peasy modals

<div x-data="{ open: false }">
  <!-- Modal trigger-->
  <button @click="open = true">Open Modal</button>

  <!-- Modal outer container-->
  <div x-show="open">

	<!-- Modal inner container - if you click outside, the modal will closes-->
	<div @click.away="open = false" class="fixed inset-0 bg-black/50 flex items-center justify-center">
	  <div class="bg-white p-4 rounded">
		<p>Click outside the modal to close it</p>
		<button @click="open = false">Close</button>
	  </div>
	</div>
  </div>
</div>

Click outside the modal to close it

Hire an expert web developer for less

The average salary for a junior dev in the US is $70,000. Hiring me costs about 25% less.

Piccolo

$5,500/mo

  • One concurrent request

  • Turnaround time in days, not weeks
  • Pause or cancel anytime
Schedule an intro

Grande

$8,000/mo

  • Two concurrent requests

  • Turnaround time in days, not weeks
  • Pause or cancel anytime
Schedule an intro

Have questions?

Learn more about how I work and discuss your project on a free call.

Schedule a call

Unsure? Let's make this really easy for you.

Within the first 3 weeks of your initial month, if you're not completely satisfied for any reason, just let me know, and I'll will refund your fee and cancel your subscription. That's something you wouldn't get from a full-time employee or some random freelancer.