Open halcarleton opened 11 months ago
I'm running into the same issue, but with @rainbow-me/rainbowkit
which are imported as follows inside both preview.tsx
and also inside providers that I'm wrapping the stories in, neither has any effect in the Storybook environment:
import "@rainbow-me/rainbowkit/styles.css";
UPDATE: I was able to get the styles to be applied by adding this to main.ts
:
{
name: "@storybook/addon-styling",
options: {
postCss: true,
},
}
I know that package is deprecated, so you may need to install one of the two that it split into if you go this route.
@halcarleton did you find a work around by any chance?
Another work around which is more feasible is to create a globals.css
or globals.scss
depending on what you are using and add import the css from the "node_modules" there for example:
// globals.scss or globals.css file
@import '@radix-ui/themes/styles.css';
and then in you storybook .preview.ts
file import the globals.scss or css file:
// .storybook/preview.ts or .storybook/preview.tsx file
import '../globals.scss'
This worked for me!
@efaraz27 that worked for me as well, thank you 🙇
experiencing this as well, @efaraz27 workaround worked for me 👍
Describe the bug
Importing a 3rd party CSS file _(CSS file in
node_modules
)_ into the.storybook/preview.tsx
file does not result in that CSS being loaded into the preview iframe.To Reproduce
Reproduction repository: https://github.com/halcarleton/storybook-radix-issue
This is a bare bones NextJS app created with:
Then Radix theme is installed and integrated into both the Next app and the Storybook preview.
Steps to repro:
npm install
npm run dev
npm run storybook
Additional debugging steps:
styles.css
file and paste it into the project's./src/app/globals.css
file.npm run storybook
This suggests that the issue is not with the imported CSS file, but instead seems to be specific to importing from
node_modules
.For quick reference, this is the content of the
.storybook/preview.tsx
file:This is the base content initialized by the
storybook init
command. The updated pieces are:System