Skip to content

Support for 'disabled' attribute #41

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

Closed
robrechtme opened this issue Feb 6, 2021 · 3 comments
Closed

Support for 'disabled' attribute #41

robrechtme opened this issue Feb 6, 2021 · 3 comments

Comments

@robrechtme
Copy link

Hi!

First of all, love the plugin!
Is there any reason why the disabled attribute is ignored?
There is no visual difference anymore between the two:

https://play.tailwindcss.com/uEon0s582K?file=config

I can look into making a PR, if you think that would be a nice addition.

@frederikhors
Copy link

I can look into making a PR

please

@adamwathan
Copy link
Member

It's not really that it's ignored, just that we don't have to do anything special to make disabled states styleable. This plugin isn't designed to make forms automatically look good or anything, just make them work more easily with utilities. How you want things to look when they are disabled is hard to generalize, the styles would be different in each project.

The recommended approaches to styling disabled form elements are either:

  1. Just add utilities whenever you add the disabled attribute, usually with JS. Might look something like this:

    <input className={`... ${formDisabled ? 'opacity-50' : ''}`} disabled={formDisabled} />
  2. Use Tailwind's disabled variant (not enabled in Tailwind by default)

    <input class="... disabled:opacity-50" disabled />

No plans to add disabled styles by default as I think that would actually make it harder for people to use custom disabled styles, since they would be forced to enable the disabled variant to defeat the default disabled styles. Hope that makes sense.

@robrechtme
Copy link
Author

Thank you for your insights. I didn't know if it was intentional or not, but now that you've told me the reasoning behind it I totally understand.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants