Skip to content

How can I choose the priority when styling different states? #634

Answered by nmn
dd-jonas asked this question in Q&A
Discussion options

You must be logged in to vote

Pseudo classes have an internal defined order. Same with media queries. You're expected to define styles with mutually-exclusive conditions when it matters by nesting additional levels.

So your contrived example would look like this:

export const styles = stylex.create({
  backgroundColor: {
    default: 'black',
    ':focus': {
      default: 'red',
      ':hover': 'green',
    },
  },
});

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
4 replies
@nmn
Comment options

nmn Jul 9, 2024
Collaborator

@dd-jonas
Comment options

@nmn
Comment options

nmn Jul 15, 2024
Collaborator

Answer selected by dd-jonas
@dd-jonas
Comment options

Comment options

You must be logged in to vote
2 replies
@dd-jonas
Comment options

@BMCwebdev
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants