live_toast icon indicating copy to clipboard operation
live_toast copied to clipboard

The #client-error and #server-error toasts don't work with Tailwind 4.

Open Huxelpux opened this issue 9 months ago • 7 comments

The standard #client-error and #server-error toasts don't work with Tailwind 4.

The reason seems to be that they both have a hidden attribute, which is not reset ever. With Tailwind 3, the class takes precedence over the hidden attribute, in Tailwind 4 the hidden attribute takes precedence over the class.

Huxelpux avatar Apr 03 '25 21:04 Huxelpux

Interesting, thank you for the report! Should be pretty easy to fix.

srcrip avatar Apr 04 '25 19:04 srcrip

I suspect opacity must also be fixed - if one removes the hidden attribute in the browser inspector, the toasts still cannot be seen, as they have an opacity of 0%.

Huxelpux avatar Apr 05 '25 20:04 Huxelpux

For me the positioning doesn't work (it's full width instead of anchored in a corner), and the close icon isn't visible:

Image

dfalling avatar Apr 09 '25 21:04 dfalling

This turns out to be a bit more complicated than at first glance, because the library doesn't ship it's own CSS, it just assumes you're going to use TW, and ships the markup of the components with TW css, and has you point your TW config at the lib.

TW 4 also has breaking default changes. So if I were to change things to work in v4, it would mean they wouldn't work right in v3 any more.

We'll have to think through the right approach here. I can't assume everyone is ready to move to v4 and just break it for everyone else. But also maintaining two versions seems like it would really suck.

srcrip avatar Apr 15 '25 18:04 srcrip

Ok, I've given this some thought and I think a good path forward may actually be that the consumers of this library totally own their 'toast component' code, ie., we use a generator to paste it into your components file or just ask you to copy it in yourself. That way we could just have a TW v3 and v4 version.

The only tricky thing is we also have classes on the toast group container. I'm not quite sure what to do about that cause ideally you wouldn't also need to copy that in. But I don't know. Going to give it some more thought.

srcrip avatar Apr 17 '25 15:04 srcrip

Could the user own the group container too? For example, the generator could create a new lib/__myapp__web/components/live_toast.ex component that has the html for the container and the individual flash elements? We then import that <.live_toast /> in our layouts instead of the <LiveToast.toast_group.

Then we also wouldn't need corner={:top_right} as we could tweak that directly ourselves.

dfalling avatar Apr 17 '25 19:04 dfalling

Yeah, I have the same issue as @dfalling.

Wouldn't the best approach just be to ship the CSS with the library?

dmkenney avatar Jul 14 '25 17:07 dmkenney