#Storybook v7 doesn't recognize custom MUI theme color?
1 messages · Page 1 of 1 (latest)
Do you have your theme defined/imported in preview.js?
Hmm, no
https://storybook.js.org/blog/material-ui-in-storybook/
I found this, but it has several examples of the preview file and each looks different
Do I use something like this before/after the parameters constant?
import { CssBaseline, ThemeProvider } from "@mui/material";
import { darkTheme } from "../src/themes/dark.theme";
/* snipped for brevity */
export const withMuiTheme = (Story) => (
<ThemeProvider theme={darkTheme}>
<CssBaseline />
<Story />
</ThemeProvider>
);
export const decorators = [withMuiTheme];
Ok I think I managed it, hope it doesn't break. Thank you very much for the hint!
@sterile sedge is putting together some guides of how to do this kind of thing I think. Hopefully it will be easier in the future
Just in case you want it, I just released an addon that will clean things up a bit for you 😄
Hmm, looks interesting, that would be the tidier way basically
Absolutely 🙂
I will try it out 🙂
We've gotta get the word out on this addon...
Since you're here, allow to me make a quick question. As far as I understood SB uses as controls whatever it finds in the interface/type of the props of the component it renders. Is there a better way of only having it include into the controls the args that you specify other than adding this into the meta?
ahaha right? I'm updating our recipe pages to use it as we speak and it will come up at Storybook day
Ideally it would only use the args that you specify as controls, with some sort of parameter that takes a boolean in case you want it to use everything else it finds as well
That's a great question, Peter! Right now, I don't think that there is but I can see why that would be useful 🤔
According to chatGPT, the last version it knew (6.1) did exactly that. Maybe without that parameter I mentioned, but it only used the args you provided as controls
or maybe something like:
parameters: {
controls: {
include: 'argsOnly',
}
}
Right, sorry I was proposing what it would look like if what you suggested existed
I believe so
Ok, thank you very much, I'll give the addon a try too!
hmmmmm actually
So how about this...
const Stepper = Template.bind({});
Stepper.args = {
step: 1,
someProp: '',
}
Stepper.parameters = {
// Will only include controls for "step" and "someProp"
controls: { include: Object.keys(Stepper.args) }
}
Hmm, is that applicable for v7?
It should do