In this episode, we finally tackle that annoying flicker you see before Alpine fires up and hides an element. If you've been following along, you know it's a common issue when using directives like x-show
—your hidden content sneakily appears for a split second while Alpine initializes.
We dive into what x-cloak
actually does: it's just an attribute that Alpine automatically removes once everything’s set up. By itself, it doesn’t do anything with styles, but that's where the neat trick comes in. We show you how to globally add a style for [x-cloak]
, setting display: none !important
to hide any element with the x-cloak
attribute. This way, your hidden elements stay hidden—right from the get-go—until Alpine is ready to take over.
You'll see a demo comparing the difference with and without x-cloak
, and we even tweak the example by adding a button to toggle the reveal, showing how the attribute is removed when it's no longer needed.
By the end of this video, you’ll have a super simple solution to banish that content flicker for good in your Alpine-powered interfaces.