Conditional display of an HTML element part of a stream

Nice – glad you got it working!

Funnily enough, it just hit me that you don’t even need a client side hook since you can show/hide/toggle visibility with JS Commands even within streams.

You can tag the streamed elements you want to show/hide via id, class, or data attributes and then use some input e.g. button to show/hide them via
phx-click={JS.show/hide/toggle(to: "id/class/attribute dom selector")}

2 Likes