Skip to content

Chakra-UI Menu colors override causes breaking of selected item colors fix #274

Answered by csandman
intivillca asked this question in Q&A
Discussion options

You must be logged in to vote

Ok I actually have an alternative solution that could work for you! I was looking at Chakra's own Menu component and wondering why the _dark styles they have applied don't override the style props or sx props you add directly to the components. Like this, where I'm focusing the menu item:

And I checked the styles and realized, that's probably the whole reason they started using the cssVar utility function to add component scoped css variables. When you add a custom style on the component itself, it just overrides the base style which was previously referencing the css variable.

Before the custom style

After the custom style

If you take a look at their theme file for the Menu, you can s…

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@intivillca
Comment options

@csandman
Comment options

@intivillca
Comment options

@csandman
Comment options

Answer selected by intivillca
@intivillca
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
2 participants