Storybook styles given higher precedence than project styles
See original GitHub issueIf you are reporting a bug or requesting support, start here:
Bug or support request summary
I’m importing my base style reset in preview.js, it does normal reset things and also sets our app fonts. However when I load storybook I end up with
section {
font-family: 'Nunito Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 14px;
line-height: 24px;
padding: 48px 20px;
margin: 0 auto;
max-width: 600px;
color: #333;
}
overriding my set default line-height, font-family, etc. This causes an obvious issue for component development.
I’m sure there is some setting I need to change or something I’m missing but I’m basically using storybook 6 out of the box in a CRA typescript project. I’ve installed the preset scss since we use Sass
//main.js
module.exports = {
stories: ["../src/**/*.stories.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
addons: [
"@storybook/preset-scss",
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/preset-create-react-app",
"@storybook/addon-actions",
],
};
//preview.js
import "../src/index.scss";
If there is a class set on an element it wins out in specificity, but all of the app defaults seem to lose.
This is coming from an experiment in using MDX in case that is relevant?
import { Meta, Story } from "@storybook/addon-docs/blocks";
import PassFail from "./pass-fail";
import { options } from "../select.stories.mdx";
<Meta
title="Components/Forms/PassFail"
component={PassFail}
argTypes={{
onPassClick: { action: "successClick" },
onFail: { action: "failClick" },
reasonList: { type: "data", defaultValue: options },
label: { type: "string", defaultValue: "This is a test" },
}}
/>
# Pass/Fail Element
Adds pass fail combo button with dropdown for fail reasons
export const Template = (args) => <PassFail {...args} />;
<Story name="Default">{Template.bind({})}</Story>
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (3 by maintainers)
Top Results From Across the Web
6 Ways To Configure Global Styles for Storybook | by Jennifer Fu
This import has higher precedence than the head styling. Refresh the Storybook, and we see the background is changed to yellow . Storybook...
Read more >Styling and CSS - Storybook
Storybook is a frontend workshop for building UI components and pages in isolation. Thousands of teams use it for UI development, testing, and...
Read more >Tailwind css classes not showing in Storybook build
When running build-storybook the components are rendered with the tailwind classes. Unfortunately, when I build storybook and run the create ...
Read more >How to Build a Fullstack Next.js App (with Storybook ...
If you choose not to use Tailwind, you can either keep the styles ... So we'll give the designer a break on this...
Read more >4 Ways to Override Material UI Styles | by John Au-Yeung
Material UI offers more than just a single way to override its styling. That's great for us but it can also be very...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@shilman can one reopen this issue? Its not resolved and does have some direct side-effects that affect how our applications behave.
@ArmanNisch I think it’s being addressed here https://github.com/storybookjs/storybook/pull/19433