🚨 Pay Just $95/Year (Save 50%)β€”Black Friday Deal!

#140 Click outside to close Menu with Stimulus-Use

12/08/2023

Click outside element to hide it - this might be one of the most common javascript tasks!

We will leverage Stimulus-use and it's clickOutside behaviour to trigger an action on a stimulus controller. In our case - to close the dropdown menu.

Episode source code: https://github.com/corsego/138-tailwind-layout/commit/f58de741ddd87b52ededc1fcee5b7d0b8f67f229
Based on this blogpost: https://blog.corsego.com/tailwindcss-dropdown

P.S. πŸ™ˆ Really, I just forgot to include this feature in the previous episode, so here you go. This might be my shortest episode yet!

0
Join the conversation
Sign in to access PRO lessons, access private repos, leave comments, create watch lists.
We collect your email address, name and username to create your account. We do not share your email address with anyone else.