Sebastian De Deyne
Designer & developer at Spatie

Reusable Alpine Components by Ryan Chandler

ryangjchandler.co.uk

I’ve been using Alpine often lately. Ryan has written a lot of good stuff on Alpine, but his reusable components post is what really got me kickstarted.

You should be careful to not abstract too early. If you are finding it difficult to manage your Alpine component from the x-data attribute, this one is definitely for you.

The way this article builds up was very helpful: only use the level of abstraction you need:

  1. No abstractions
  2. Extract to a component function
  3. Use x-spread
  4. Mix in other data

If you enjoyed this post, you might be interested in my newsletter. I occasionally send a dispatch with personal stories, things I’ve been working on in the past month, and other interesting tidbits I come across online.