![[Elixir Tip]: Fade-out flash in Phoenix LiveView 0.17 and TailwindCSS](https://www.coramsoftware.com/images/screen-shot-2021-08-18-at-8-47-10-am.png)
This is a short snippet on how to do fade-out on @flash outputs, for Phoenix LiveView 0.17! Yes the latest one, utilizing Phoenix.LiveView.JS commands.
The effect I was going for was when there are new flashes, the flash would automatically fade out, after waiting a couple seconds, so that the user will be nudged but message will still fade away.
This will do the animation, and then lastly fire a JS.push() to clear out the flash at the server.
Files that are needed are:
app.js- to set up event handler to processing event message coming from server, and to run the JS command assigned to target attributecomponent.ex- your LiveComponent filecomponent.html.heex- code for showing flash, and to have the target attribute, andphx-value-keyattributetailwind.config.js- optional, just showing how to add custom duration / delays if you need them
Check out the code in its entirety here: