by maxloh · 1y ago · 0 comments
<div>
{#each colors as color, i}
<button
style="background: {color}"
aria-label={color}
aria-current={selected === color}
onclick={() => selected = color}
>
{i + 1}
</button>
{/each}
</div> <div x-data="{ open: false }">
<button @click="open = true">Expand</button>
<span x-show="open">
Content...
</span>
</div>Nobody wants to express complex conditions all around the UI when derived state can be handled in a single store.
I think I'm fond of it because I've never grown to love html-in-js. Sometimes you definitely need that, but for apps that are simple enough that you don't, I find Alpine is just nice to use. No build steps at all, every editor knows how to color html, etc.
It probably shouldn't become a web standard though.
The code came directly from Svelte's official tutorials. Looks like I accidentally copied the problem instead of the solution!