question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is your feature request related to a problem? Please describe. I want to be able to reference other theme values from the theme itself. Sorry if this is already a feature!

Describe the solution you’d like Ideally, the same way react-i18next works. You can reference strings from the same file with the nesting feature.

Describe alternatives you’ve considered Hard-coding values or not putting nested styles inside, neither of which are ideal.

Additional context I want to be able to set primary colour like this.

colors: {
  gray-500: '#ccc',
  primary: 'gray-500',
}

This currently does not work, I have to hard-code primary value and leave a comment explaining what it is. The same applies for other keys in the theme object I believe.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
hasparuscommented, Nov 20, 2020

Closing in favor of #1234

This currently does not work, I have to hard-code primary value and leave a comment explaining what it is. The same applies for other keys in the theme object I believe.

There is a workaround btw.

const baseColors = {
  blue: {
    '500': '#00f'
  }
}
const moreColors = {
  primary: baseColors.blue['500']
}
const colors = {
  ...baseColors, ...moreColors
}
2reactions
atanasstercommented, Nov 19, 2020

@hasparus I think we can close this in favor of #1234

Read more comments on GitHub >

github_iconTop Results From Across the Web

Theme nesting with Material UI - reactjs - Stack Overflow
There are several different styles I need to apply to some of them. I want to create a global theme for handling everything...
Read more >
Theming - Material UI - MUI
The theme specifies the color of the components, darkness of the surfaces, level of shadow, appropriate opacity of ink elements, etc. Themes let...
Read more >
Nesting themes | React Material-UI Cookbook
By nesting MuiThemeProvider components, you can compose multiple themes that handle different aspects of a theme into a single theme that's suitable for...
Read more >
Theme Nesting Doesn't Work (seems has something to do ...
Theme Nesting Doesn't Work (seems has something to do with storybook) #29087 ; Current Behavior ; Expected Behavior ; Steps to Reproduce.
Read more >
Nested Theme Providers - Theme UI
The nested ThemeProvider component can use a functional theme to avoid deep merging the objects or to control the way the two objects...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found