sx prop not applied in Storybook, but applied successfully in Next.js app #1873
-
Describe the bug We faced a few problems to get that tech stack working. Everything builds just fine: The Next.js app builds fine, Storybook builds fine. Maybe you can help me with this? I built a small repo for you to reproduce the issue. To Reproduce Steps to reproduce the behavior:
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
Hey @seisenreich I believe this is a duplicate issue.
|
Beta Was this translation helpful? Give feedback.
-
Hi @fcisio , I thought so at first, too. What didn't get fixed was the support of the sx prop. I don't know if the problem is caused by the same thing, though. |
Beta Was this translation helpful? Give feedback.
-
Also the styles in my case look a bit different. Fun thing you can see here: |
Beta Was this translation helpful? Give feedback.
-
Okay, so the JSX pragma running in Storybook doesn't know about Edit: I cloned your repo and managed to fix it. Add the following to .storybook/.babelrc to tell Storybook about your Babel setup. {
"extends": "../babel.config.js"
} Explanation: The part of configuration that makes
We tell Next's Babel Preset to tell Babel Preset React that all JSX will be from now on handled by Storybook didn't detect your Babel config, so no JSX pragma there. Thanks for the repro, @seisenreich, it helped a lot. Screenshot after my change: |
Beta Was this translation helpful? Give feedback.
Okay, so the JSX pragma running in Storybook doesn't know about
sx
prop.Is your Storybook using the same Babel config as your Next.js app?
Edit: I cloned your repo and managed to fix it.
Add the following to .storybook/.babelrc to tell Storybook about your Babel setup.
Explanation: The part of configuration that makes
sx
prop work on intrinsic elements like<div />
is this:We tell Next's Babel Preset to tell Ba…