question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Storybook styles given higher precedence than project styles

See original GitHub issue

If 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:open
  • Created 3 years ago
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

6reactions
ArmanNischcommented, Jan 17, 2022

@shilman can one reopen this issue? Its not resolved and does have some direct side-effects that affect how our applications behave.

1reaction
shilmancommented, Oct 24, 2022
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found