I am new to Tailwind CSS and CSS in general. I need to make my buttons stop doing transform/transition effects when they are disabled. Currently, the disabled color changes are getting applied but the transformations/transitions are still taking place on hover.
I tried using - disabled:transform-none and disabled:transition-none but it is not giving the desired result.
Technologies being used is - ReactJS, Tailwind CSS
The dummy code snippet with the classes used is as follows:
<button
disabled={disableIt}
className="text-xs rounded disabled:transform-none disabled:transition-none disabled:bg-gray disabled:cursor-not-allowed disabled:text-white bg-gray-600 mx-1 transition duration-500 ease-in-out transform hover:translate-x-1 hover:scale-110 hover:blue-300 hover:shadow-md"
>
Click me
</button>
Note: disableIt is a state that is used to disable or enable the button
My tailwind.config.js is has the variants section as:
variants: {
opacity: ({ after }) => after(["disabled"]),
backgroundColor: ({ after }) => after(["disabled"]),
textColor: ({ after }) => after(["disabled"]),
hover: ({ after }) => after(["disabled"]),
cursor: ({ after }) => after(["disabled"]),
transition: ({ after }) => after(["disabled"]),
transform: ({ after }) => after(["disabled"]),
extend: {
padding: ["hover"],
},
},
Please help me out.
<button>
. Note: it doesn't work with<a>
links – Mamey