-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: setComponentThemes equivalent in 0.12 #1812
Comments
Are you using a custom theme or a built in theme? If you are not using a custom theme, I highly recommend that you do. I have a custom theme and I'm setting it using my custom theme. So here's how it would look in your case. Let's assume you have a custom theme, and in that custom theme, you set those properties in the raisedButton object. You've also used Theme Manager to set your custom theme. So now in your component code, require your custom theme "require('path/to/custom/theme.js')" Then do this, CustomTheme.ComponentThemes(CustomTheme.palette, CustomTheme.spacing).raisedButton; These are the functions available to us in material-ui 0.12 via ThemeManager: modifyRawThemeSpacing: function modifyRawThemeSpacing(muiTheme, newSpacing) { //function to modify the palette of the raw theme. This function recomputes //function to modify the font family of the raw theme. This function recomputes and none of those seem to do what you are looking for so I think custom theme is the way to go. |
Thanks for your reply @sothychan. I am using a custom theme as specified in the docs. So I can apply my styles like this?
|
I haven't actually tried it like that, but give it a shot. I don't see why that wouldn't work. If that doesn't work, you need to modify the raisedButton object within your CustomTheme.js. For example, in my custom theme.js, I have this block for raisedButton:
so in my component I have this:
Let me know if you have any questions. |
Ah, this isn't quite what I'm looking for. Here's a snippet from the source-code: (flat-button.jsx)
I'm pretty sure I can apply styles to the component without explicitly passing them as a style prop, as it should be passed through context. I just need to figure out how this works in the new version. Update: I've somewhat figured out how to set custom properties on the muiTheme context object, I've done it like so:
It works for now but I'm sure this isn't the correct solution to apply global styles to mui components. |
I've been working with this as well, and think the API would benefit from some more flexibility here in the form |
@epferrari Seems like a good suggestion, @hai-cea could you take a look at this thread when you have time and give us some input? Would be greatly appreciated, thanks. |
What is the |
The theme is again changing with the upcoming |
Hi guys, I've recently updated to material-ui 0.12 so I could utilise the updated tab components, however I'm slightly confused by the changes in the theme system. I used to be able to do this:
However this seems to have been deprecated, and I can't find any examples of setting component-specific styles. Do I have to create a custom component with inline styles in order to do this, or is there a new way?
Thanks in advance.
The text was updated successfully, but these errors were encountered: