Level 75
All I see is https://github.com/alpinejs/alpine#x-if
But you could setup two x-if constructs.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi Peeps,
Is there such a thing as x-if AND x-else in Alpine.js?
<template x-if="func()">
Do stuff if truthy
</template>
<template x-else">
Do the falsey stuff
</template>
If there isn't I'd have to call func() twice or make my components logic massively long!
TIA
Please or to participate in this conversation.