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.

Allow function for theme.overrides

See original GitHub issue

It will be fine to have theme properties available when overriding component style.

Example of usage:

const theme = createMuiTheme({
  overrides: {
    MuiButton: theme => ({
      root: { backgroundColor: theme.palette.secondary  }
    })
  }
})

May I create PR? Solution is to add

if (typeof overrides == 'function') overrides = overrides(theme)

after line 14 in styles/getStylesCreator.js

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
oliviertassinaricommented, Dec 8, 2017

Let me know when you have something compatible with react-native. I’m eager to know more about it 😃.

0reactions
oliviertassinaricommented, Jun 23, 2021

@ndeviant I don’t get the problem. You can create a function to abstract the duplication/ternary operators.

It resonates a bit with option 2 in https://github.com/mui-org/material-ui/issues/26813#issuecomment-864615252 where the theme is also available as part of the props.

Read more comments on GitHub >

github_iconTop Results From Across the Web

A Guide to Overriding Parent Theme Functions in Your Child ...
In this tutorial, I'll show you three methods you can use to override functions from the parent theme in your child theme:.
Read more >
Allow function for theme.overrides · Issue #9443 · mui/material-ui
It will be fine to have theme properties available when overriding component style. Example of usage: const theme = createMuiTheme({ overrides: ...
Read more >
how to override parent theme's function ? | Drupal.org
I'm making a subtheme and I need to replace a function of the parent theme (defined in .theme file) by my own. How...
Read more >
How to override parent theme functions in a child theme
Taking advantage of pluggable functions – an easy way for overriding parent theme functions but only possible if your parent theme is making...
Read more >
How to override parent theme functions in WordPress
When writing a parent theme, it's good practice to make your functions pluggable so that you can easily override them in child themes....
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