Comments (5)
I have run into this issue as well after migrating to Storybook 8. I have some documentation-only MDX pages with examples embedded in a Canvas so that I can have isolated CSS and code examples. The examples render when I remove the Canvas, but they don't render correctly because Storybook's CSS conflicts with my component's CSS.
from storybook.
This is because Canvas block no longer accepts children. It now refers to a single story with of prop.
Spot on @AimenKhalidArbisoft
I guess I could turn the code that was previously wrapped in Canvas into a story, but I really don't want it to appear in the navigation. Is there a way to "hide" a story in the sidebar?
@axelboc We're introducing a built-in way to do this in 8.1 using tags. See the docs on the tags-API here (alpha): https://storybook.js.org/docs/8.1/writing-stories/tags
In short, removing the 'dev'
tag from a story by giving it '!dev'
will hide it from the sidebar, but still be targetable with <Canvas of={...} />
. This makes it possible to define any story you want, and have it shown/hidden in the sidebar/docs however you want.
... so that I can have isolated CSS and code examples. The examples render when I remove the Canvas, but they don't render correctly because Storybook's CSS conflicts with my component's CSS.
@benfosterlitmos have you looked into the <Unstyled>
doc-block to disable Storybook's styles? https://storybook.js.org/docs/8.1/api/doc-block-unstyled
It doesn't remove all styles because of some inheritance limitations, but the default styles have so low specificity that they should easily be overridable with your own styles if you want to.
I'm closing this as this is intended behavior and not a bug - but keeping the discussion open if you have further questions. If you need a way to wrap arbitrary JSX in a Canvas-like element, please open an RFC explaining the use cases, and how it would be better than the current state of things. I'd propose you come at it with fresh eyes, disregard what you know from the old behavior but come at it with a "what is my current problem, how would I like it to be solved"-mentality
from storybook.
This is because Canvas block no longer accepts children. It now refers to a single story with of prop. Try removing the Canvas wrapper altogether. I tried this and it worked. Apparently in v6, you needed the canvas wrapper to render jsx in mdx but this is no longer the case. I assume it is due to the fact that sb v8 used mdx3 instead of mdx1 now.
from storybook.
Oh that's a shame. It works if I remove the wrapper, of course, but the point is to show the Canvas
UI (i.e. mostly the ability to show the source code). I guess I could turn the code that was previously wrapped in Canvas
into a story, but I really don't want it to appear in the navigation. Is there a way to "hide" a story in the sidebar? Reading through #9209, it doesn't seem straightforward...
from storybook.
Same problem here, I would like to know if there is another alternative ?
from storybook.
Related Issues (20)
- [Bug]: Error with static storybook HOT 2
- [Bug]: Configuration options don't seem to get passed on to vitest HOT 2
- [Bug]: Next 14.2.2 [ yarn dlx sb init -> running storybook error ] HOT 1
- [Tracking] On-going effort to fix flakey tests
- [Bug]: Empty index.html
- [Bug]: docs tab not display in storybook ui HOT 3
- [Bug]: defaultProps Warnings HOT 1
- [Bug]: Failed to execute 'insertRule' on 'CSSStyleSheet' : Storybook 8.0.6
- Check command seems to be inconsistent HOT 1
- [Bug]: Docs stories filtered with `'!autodocs'` behaves weird in `Primary`, `Stories`, `Controls`, etc. components HOT 4
- Bench script flakiness
- [Bug]: Can't install latest version with the Next.js option HOT 1
- [Bug]: Typescript JSX types for Vue3 (Vite project) . The type of the tsc command is incorrect
- [Bug]: Not possible to map complex types to different types with typescript and react
- [Bug]: Load component fail after publish HOT 1
- [Bug]: @storybook/addon-controls break some stories HOT 4
- [Bug]: Viewports arenβt reset when navigating away from a story with a default viewport HOT 1
- [Bug]: Footer of save-from-controls position is not attached to bottom of the panel
- [Bug]: Error: 'MissingStoryAfterHmrError' is not exported by node_modules/@storybook/core-events/preview-errors.js, imported by node_modules/@storybook/preview-api/dist/index.mjs
- [Bug]: "The `docs.autodocs` setting in '.storybook/main.js' is deprecated." Appears even after migrating
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from storybook.