Skip to content

Using hover and focus variants when not disabled #3574

Answered by simonswiss
amiranagram asked this question in Help
Discussion options

You must be logged in to vote

Hey!

In short: you can do the opposite of what you want: Add disabled styles if the button is disabled. These will "cancel" any hover/focus styles you have applied on the same element.


Detailed answer

You can enable the disabled variant for what you need (like backgroundColor, textColor) in your config file's variants.

If a disabled: style is set for a button, it will never allow hover/focus styles to show. Here's an example in Tailwind Play:

https://play.tailwindcss.com/LOaudRbGXs

Notice how I enabled the disabled variant for both the background and text colors, and then applied disabled styles to both buttons (one of them having the disabled attribute).

Hope it helps 👍

Replies: 4 comments 8 replies

Comment options

You must be logged in to vote
1 reply
@amiranagram
Comment options

Answer selected by amiranagram
Comment options

You must be logged in to vote
6 replies
@adamwathan
Comment options

@prince272
Comment options

@bauhaas
Comment options

@selemondev
Comment options

@ctoma
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@Nases
Comment options

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