iam

iam

Hi all,

the class phx-no-feedback:hidden is applied correctly in the DOM but I got no style for it in the css.
Should I add something special in the tailwind config to generate the css for that class?

The LV docs says:
Now, any DOM container with the phx-feedback-for attribute will receive a phx-no-feedback class in cases where the form fields has yet to receive user input/focus. Using new CSS rules or tailwindcss variants allows you errors to be shown, hidden, and styled as feedback changes.

Which is not helpful. Maybe the LV docs could link to the relevant part in the Tailwind docs?
Or maybe this should work OOTB and I just have to adapt my configuration.

Thank you

Showing Posts 1 to 9

Ankhers

Ankhers

You may nor may not be the same person that asked on IRC, so I will also answer here.

In a freshly generated Phoenix 1.7 application, there is a section in the tailwind.config.js file that has additional variants listed. I will just copy the relevant section here.

    plugin(({addVariant}) => addVariant("phx-no-feedback", [".phx-no-feedback&", ".phx-no-feedback &"])),
    plugin(({addVariant}) => addVariant("phx-click-loading", [".phx-click-loading&", ".phx-click-loading &"])),
    plugin(({addVariant}) => addVariant("phx-submit-loading", [".phx-submit-loading&", ".phx-submit-loading &"])),
    plugin(({addVariant}) => addVariant("phx-change-loading", [".phx-change-loading&", ".phx-change-loading &"])),

There are also more things in the config that may be worth looking at. So it may be worth generating a brand new project just to see what is there in case it is relevant to you.

AlchemistCamp

AlchemistCamp

Do you know where the actual source for those styles is? I’ve generated a new project to copy them from, but they don’t appear anywhere in the assets directory or in the deps directory for the Tailwind module.

To clarify, I’m on Phoenix LiveView 18.6 and using the same core components that ships with Phoenix 1.7.1 and Tailwind, but still stuck with Webpack due to some dependencies that aren’t don’t work well with ES Modules. I just need the CSS that’s injected by the Tailwind “phx-no-feedback” plugin.

Ankhers

Ankhers

This has to do with tailwind, not webpack/esbuild.

If you take the lines I used above and added them to your tailwind.config.js file in the plugins section you should also have access to these styles. If you are unsure, take a look at the freshly generated tailwind.config.js file and copy over the added parts to your projects config.

AlchemistCamp

AlchemistCamp

I could have elaborated a bit more. Due to the fact that the app has many tens of thousands of lines of SCSS, Bootstrap and Font Awesome, it’s very difficult to migrate to normal Tailwind setup. My planned path for that is to get everything migrated to ES 6 modules and then use Vite, which supports SCSS out of the box and is also very easy to use Tailwind with.

As of now, I’m managing Tailwind classes semi-manually and do not have a tailwind.config.js. This is why I asked where the actual phx-no-feedback styles were.

Ankhers

Ankhers

In that case you are going to need to look at the compiled app.css file that is output after being run through tailwind. That will have all of the styles that tailwind generates for you.

AlchemistCamp

AlchemistCamp

Are you sure there isn’t some kind of documentation or maybe a standalone repo for the plugin?

LostKobrakai

LostKobrakai

There isn‘t. The „plugins“ are a handful lines of js code in the tailwind.config.js, which for the most part tells tailwind how to scope css selectors to the presence or lack of presence of the classes liveview will add to inputs or paren dom nodes.

E.g. phx-no-feedback:hidden converts to

.phx-no-feedback.phx-no-feedback\:hidden,
.phx-no-feedback .phx-no-feedback\:hidden{
  …
}

as configured by

plugin(({addVariant}) => addVariant("phx-no-feedback", [".phx-no-feedback&", ".phx-no-feedback &"])),
…

The plugins make using tailwind in the context of liveview simpler, but the underlying css is not coupled to tailwind at all.

AlchemistCamp

AlchemistCamp

Ah, right. I see what the variant is doing now, thanks.

What I’m trying to figure out is what classes I should add to my templates to hide the appropriate fields. I guess the question I should have asked is, “for which classes or selectors should I hide so as not to show feedback for fields a user hasn’t interacted with yet?”

AlchemistCamp

AlchemistCamp

The solution was trivial! All I needed to add to my global scss file was:

.phx-no-feedback .phx-no-feedback\:hidden { display: none; }

There wasn’t any more complexity than that to how LV updates classes on tags inside of one with phx-feedback-for set.

— All posts loaded —

Where Next? Top

Trending in Questions Top

Blokh
Hey guys, I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly Do you guys have any suggestions what is the best prac...
New
RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews