Chakra Styles not being applied in Storybook #5987
Replies: 8 comments 25 replies
-
This can be closed. I'm dumb 🤦🏾♂️ |
Beta Was this translation helpful? Give feedback.
-
I'm facing the same problem, but in my case, I think that I'm placing the custom theme in a right way. main.js
preview.js
All the components appear, but they don't get my custom theme. =/ @ntwrkjasen can you explain how have you managed to solve that? It can help me out on this one. Thanks. |
Beta Was this translation helpful? Give feedback.
-
for rest of fellow searcher who are still banging their head for solution, this is how I solved it understanding from this thread. Add this in preview.js
In Component
Hope it helps :) |
Beta Was this translation helpful? Give feedback.
-
I ran into a similar problem and it was because my theme wasn't importing correctly into Note the 2 changes:
|
Beta Was this translation helpful? Give feedback.
-
None of the suggestions above have worked, so I created a repo to debug the problem: https://github.com/gabrielfgularte/chakra-storybook. Please, refer to this comment to see what I did. Although you can see the custom themed button working on |
Beta Was this translation helpful? Give feedback.
-
For me the problem was to change this:
to this
Note how under chakra, you have to specify a |
Beta Was this translation helpful? Give feedback.
-
am I also experiencing the same issue? All the answers above did not work. Any updates for this? I use storybook ^7.5.3 |
Beta Was this translation helpful? Give feedback.
-
Hey, I found the cause and a workaround: The problem is that configs on Preview.ts are not getting loaded, I don't know why, I'll leave that for someone else to figure it out, once I noticed that figuring out a workaround was pretty quick. I'm using Decorators to wrap the component on ChakraProvider, here's an example story (also, don't forget to rename the extension from .ts to .tsx) import type { StoryObj } from '@storybook/react';
import { Button, ChakraProvider } from '@chakra-ui/react';
import { extendedTheme } from 'ui';
const meta = {
title: 'Example/Button',
component: Button,
parameters: {
layout: 'centered',
},
decorators: [
(Story: any) => (
<ChakraProvider theme={extendedTheme}>
<Story />
</ChakraProvider>
),
],
};
export default meta;
type Story = StoryObj<typeof meta>;
export const Primary: Story = {
args: {
bg: 'blue',
children: 'Keep on keeping on',
},
}; |
Beta Was this translation helpful? Give feedback.
-
Hello, I've been banging my head against the wall for a few days. I'm using the official chakra ui storybook add on and can't get the chakra styles to be applied to my storybook components. Any help would be MUCH appreciated.
main.js
previews.js
theme.tsx
Beta Was this translation helpful? Give feedback.
All reactions