Romain
1 month ago

Hiding element after X seconds with Alpine

Posted 1 month ago by Romain

Hi,

I think it's all in the title :D. I can't find a way to hide a flash message after 3 seconds with Alpine. What I have so far:

                <div x-data="{ show: true }" x-show="show">
                    <div>
                        {{ session('status') }}
                    </div>
                </div>
                <script>
                    setTimeout(() => show = false, 3000);
                </script>

Any idea? Thanks

Please sign in or create an account to participate in this conversation.