Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

claydog's avatar

Alpine.js rendering - x-if and x-else

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

0 likes
1 reply

Please or to participate in this conversation.