Skip to content

Commit fcc6a69

Browse files
committed
🤖 Add Emotion CacheProvider for consistent styling in Storybook
- Wraps all stories with CacheProvider to ensure emotion works in all environments - Should fix Chromatic browser compatibility issues Generated with `cmux`
1 parent eac74e2 commit fcc6a69

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

.storybook/preview.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
import type { Preview } from '@storybook/react-vite'
22
import { themes } from '@storybook/theming';
33
import { Global, css } from '@emotion/react';
4+
import { CacheProvider } from '@emotion/react';
5+
import createCache from '@emotion/cache';
46
import { GlobalColors } from '../src/styles/colors';
57
import { GlobalFonts } from '../src/styles/fonts';
68
import React from 'react';
79

10+
// Create emotion cache for consistent styling
11+
const emotionCache = createCache({ key: 'cmux' });
12+
813
// Base styles matching the app
914
const globalStyles = css`
1015
* {
@@ -54,12 +59,12 @@ const preview: Preview = {
5459
},
5560
decorators: [
5661
(Story) => (
57-
<>
62+
<CacheProvider value={emotionCache}>
5863
<GlobalColors />
5964
<GlobalFonts />
6065
<Global styles={globalStyles} />
6166
<Story />
62-
</>
67+
</CacheProvider>
6368
),
6469
],
6570
};

0 commit comments

Comments
 (0)