Skip to content

sx prop does not correctly apply theme in nested ThemeProviders with ColorMode #1456

@rezavation

Description

@rezavation

Describe the bug

When having an application that has a nested ThemeProviders with the same theme and color modes but different values, toggling the colorMode changes the colorMode and theme in both the top level and nested theme provider, but when utilizing that theme in the nested component with the sx prop, the wrong colour gets applied.

To Reproduce
Here is a simple codesandbox that reproduces the issue. https://codesandbox.io/s/exciting-banzai-hrjom?file=/src/index.js
Expected behavior

In the example provided, I would expect the inner components background value for light mode to be "darkcyan", and it is if you print out the theme object. But when its applied to the div using sx={{ bg: "background" }} it applies "red".

Screenshot 2021-01-21 at 11 48 01

Kapture 2021-01-21 at 11 54 02

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions