Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Storybook's styling overrides all #17533

Open
chrisolsen opened this issue Feb 18, 2022 · 6 comments
Open

Storybook's styling overrides all #17533

chrisolsen opened this issue Feb 18, 2022 · 6 comments

Comments

@chrisolsen
Copy link

Describe the bug

Storybook's css seems to take priority over everything, which doesn't make much sense for a default.

The image below shows that the font-size/family for the p is being overridden by an injected css-xxx class.

image

** I do have the font that I want set in the theme, but that doesn't seem to have any effect.

// abTheme.js
import { create } from '@storybook/theming/create';
import logo from '../libs/shared/storybook-common/assets/logo-ds.svg';

export default create({
  base: 'dark',
  colorPrimary: '#005daa',
  colorSecondary: '#005daa',

  // Typography
  fontBase: 'acumin-pro-semi-condensed, sans-serif',
  fontCode: 'monospace',

  brandTitle: 'Design System',
  brandUrl: 'https://brand.ca',
  brandImage: logo
});
// manager.js
import { addons } from '@storybook/addons';
import abTheme from './abTheme';

addons.setConfig({
  theme: abTheme
});

There is also the issue of the sbdoc and sbdocs-* classes that are injected to all my components.
image

@Pegase745
Copy link

Pegase745 commented Apr 11, 2023

I know this issue is more than a year old, but I just had the problem and I solved it for the moment by setting sb-unstyled to the main container of the page.

<div className="sb-unstyled">
   ....
</div>

EDIT: even better, TIL the existence of @storybook/blocks

import { Unstyled } from '@storybook/blocks';

<Unstyled>
   ...
</Unstyled>

@btmnk
Copy link

btmnk commented Nov 10, 2023

I don't know how this is still an issue. I've read the same problem with the same workaround like 5 times today.
It's not just p tags, it's everything. You can't customize anything without !import or copy-pasting the hash-classname.
Adding <Unstyled> to every Story also seems highly cumbersome..

IMHO storybook should use a css layer for the default styles so any non-layered styles automatically get a higher cascading priority. Or the theming approach should be extended a lot so it actually provides a complete way to customize storybooks ui..

@miclgael
Copy link

miclgael commented Dec 1, 2023

Yeah, this is really weird. This is tagged has workaround but these workarounds don't work for me.

I had to get weird with it. https://gist.github.com/miclgael/73ce0297321338d4092258d99240710f

@simcha90
Copy link

simcha90 commented Jan 9, 2024

As workaround for my case just override these classes as can to do in preview-head:

p {
   display: inherit;
   margin-block-start: inherit;
   margin-block-end: inherit;
   margin-inline-start: inherit;
   margin-inline-end: inherit;
   font-family: inherit;
   font-size: inherit;
   margin: inherit;
   line-height: inherit;
   color: inherit;
}```

@KelvinOm
Copy link

KelvinOm commented Feb 6, 2024

Workaround that works for me. I added to preview.tsx the following:

import { theming } from "./decorators/theming";
import { DocsContainer } from "@storybook/addon-docs";
import { Unstyled } from "@storybook/blocks";

const preview = {
  parameters: {
    docs: {
      container: ({ children, context }) => (
        <DocsContainer context={context}>
          <Unstyled>
              {children}
          </Unstyled>
        </DocsContainer>
      ),
    },
  },
};

export default preview;

@andreLuis1506
Copy link

No one that workarounds work for me, I use nuxt3 and PrimeVue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants