-
Notifications
You must be signed in to change notification settings - Fork 225
Overridable class strategy #162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Can you give a concrete example of something that doesn't work? Are you trying to override the form styles with custom styles that you are putting in the base layer? |
Yep, that's pretty much it.
It needs to be at the base layer because, well, it is the base style. |
Those classes are in the components layer so why not use |
I guess that's work, too; apology for the fuss. Nevertheless, all strategies at the base layer have advantages in some aspects. Their consistency makes the overriding layer agnostic to the strategies used. This makes it easier to share snippets in certain situations. That said, the advantage is likely marginal; thanks for the swift replies. |
Can you verify/check if this is the case in v4? as for me, they end up in the utilities layer. which makes changing the styles and allowing overrides not work. |
In v3, I was using the In v4, this behavior changed for the
|
Source of the new behavior is this PR: tailwindlabs/tailwindcss#14221, especially the alias of components to utilities. The PR's description state:
@thecrypticace could you give us some insight into what exactly that means and how we're supposed to use utilities to override |
I was able to inline the @tailwindcss/forms plugin CSS so I don't need the plugin going forward and it works the same in v4 as it did in v3. Here's the steps I used in case it's helpful for others: I created this Tailwind Play with the form inputs I am using: https://play.tailwindcss.com/k4MfjgG3Pg (Note: Updated to @morphsteve's fixed version). Then I copied the Tailwind Play Utilities CSS into my project, and placed it inside of a ![]() |
To be clear, this plugin is basically unusable with Tailwind 4 when using the 'class' strategy. (I've always avoided the 'base' strategy because there are often 'one-off' form components which don't match the default style, and IMO it kinda goes against the Tailwind ethos.) I also used the solution above (thanks @atomgiant!) but noticed a small typo which means the textarea styles aren't included. Here's a corrected version: https://play.tailwindcss.com/k4MfjgG3Pg |
Good catch @morphsteve - I updated my comment to use your version. I use the class style for the custom form components as well. And you are right, this plugin is not usable with the class strategy unless you don't need to override the utility class styles. The @layer utilities will always win so if you set something like padding in your utility classes you can't ever change it using an inline padding, which IMO feels like a bug. I'm happy with the CSS-only version I mentioned above though, and it sounds like this is the way things may be going with other plugins like typography (i.e. - generate a CSS file rather than use a plugin). |
What version of @tailwindcss/forms are you using?
v0.5.7
Describe your issue
I read the discussion #22. The thread has been closed by adding
class
strategy.Sorry to bring this up again
However, the
class
strategy is not easily overridable because it was placed later in the CSS file (at the components layer).No matter the strategy used,
tailwindcss-forms
should always be a base, ready to be overridden by other stylings.Why the need for overrides?
I can't talk for others, as you'll see some of them on the discussion links above, but for me,
tailwindcss-forms
adds colors that almost always need overriding because they stand out like sore thumbs.What should we do?
Can we move CSS declarations of
class
strategy fromcomponents
layer tobase
layer?Basically, modify the code here:
tailwindcss-forms/src/index.js
Line 353 in c9d9da3
from
addComponents
toaddBase
.Why do I, or other similar people, use
tailwindcss-forms
at all?tailwindcss
has its ecosystem, and some 3rd-party components expecttailwindcss-forms
to be there as the base. We still want to work withtailwindcss-forms
and the people creating those components, even if we are not a fan of the approaches.The text was updated successfully, but these errors were encountered: