Giter Club home page Giter Club logo

Comments (13)

hacknug avatar hacknug commented on June 18, 2024 9

What about readonly?

from tailwindcss-custom-forms.

adamwathan avatar adamwathan commented on June 18, 2024 6

I'll likely be adding some default disabled styles in the next release but you can always just add utilities to make things feel disabled:

<input type="checkbox" class="form-checkbox opacity-50" disabled>

This is what I do currently on my own projects, never really been a painful problem.

from tailwindcss-custom-forms.

richardthombs avatar richardthombs commented on June 18, 2024 5

I'd like to be able to @apply disabled:text-gray-600 disabled:cursor-not-allowed please :)

from tailwindcss-custom-forms.

damisparks avatar damisparks commented on June 18, 2024 1

This is how I handled mine in Vue

<button
:disabled="!isFormValid"
:class="{ 'opacity-25 cursor-not-allowed': !isFormValid }"
type="submit"
class="text-white bg-primary font-semibold py-1 px-3 rounded"
>
 <span class="uppercase">Do something</span>
</button>
isFormValid() {
    // return your condition  
},

from tailwindcss-custom-forms.

barryofguilder avatar barryofguilder commented on June 18, 2024

I've been messing with the disabled state for a checkbox and having a hard time to change the icon from white to a dark gray from my Tailwind theme. Hoping to see if someone else can figure that out.

from tailwindcss-custom-forms.

MartijnCuppens avatar MartijnCuppens commented on June 18, 2024

Colorizing the check will be harder indeed since it's actually a background-image.

Other than that: should we use a disabled state per component (which is more flexible but is harder to keep in sync between components) or do we use a global disabled background-color, ect (which will require to merge the disabled theming with the components here:)?

https://github.com/tailwindcss/custom-forms/blob/454ba00d5a54deac522b2d68884bf92391136636/src/index.js#L156-L161

from tailwindcss-custom-forms.

Koc avatar Koc commented on June 18, 2024

As workaround we can define disabled state inside theme config

            default: {
                input: {
                    borderColor: theme('colors.grey.lighter'),
                    borderWidth: '1px',
                    borderRadius: undefined,
                    '&::placeholder': {
                        opacity: '1',
                    },
                    '&:hover': {
                        borderColor: theme('colors.grey.default'),
                        '&:focus': {
                            borderColor: theme('colors.grey.dark'),
                        },
                    },
                    '&:focus': {
                        outline: 'none',
                        boxShadow: undefined,
                        borderColor: theme('colors.grey.dark'),
                    },
                    '&:disabled': {
                        opacity: 0.4,
                    },
                },
            },

from tailwindcss-custom-forms.

pavelloz avatar pavelloz commented on June 18, 2024

+1 ^

Config looks like a way to go.

I would say that opacity 0.4 isnt the best choice (especially for those with weaker-contrast screens). Kind of hard to see, when there is a value already, or checkbox is checked for example. I personally use grey bg color.

from tailwindcss-custom-forms.

lukepighetti avatar lukepighetti commented on June 18, 2024

Did anyone nail down an appropriate way forward for this? Not having a disabled state for checkboxes is kind of a bummer.

from tailwindcss-custom-forms.

richardthombs avatar richardthombs commented on June 18, 2024

Actually looking at the 2.0 documentation it seems that this is possible now, right?

from tailwindcss-custom-forms.

SandroMaglione avatar SandroMaglione commented on June 18, 2024

Yes, :disabled is now available here.
@adamwathan can this issue be closed?

from tailwindcss-custom-forms.

alexcroox avatar alexcroox commented on June 18, 2024

The other missing key is disabled placeholder color. Not sure it's supported in tailwindcss as

variants: {
    extend: {
      placeholder: ['disabled']
    }
}

triggers TypeError: variantsValue is not iterable error.

Trying to do disabled:placeholder-gray-400

from tailwindcss-custom-forms.

mchev avatar mchev commented on June 18, 2024

Yes, this is possible now (using 2.0) : disabled:opacity-25 disabled:cursor-not-allowed

But you must define the appropriate variants

    variants: {
        extend: {
            opacity: ['disabled'],
            cursor: ['disabled'],
        },
    },

from tailwindcss-custom-forms.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.