You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/get-started/frameworks/nextjs.mdx
+35-65Lines changed: 35 additions & 65 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -416,84 +416,45 @@ const preview: Preview = {
416
416
417
417
[`next/head`](https://nextjs.org/docs/pages/api-reference/components/head) is supported out of the box. You can use it in your stories like you would in your Next.js application. Please keep in mind, that the Head `children` are placed into the head element of the iframe that Storybook uses to render your stories.
418
418
419
-
### Styling
419
+
##Next.js styling
420
420
421
-
####Sass/Scss
421
+
### Sass/Scss
422
422
423
-
[Global Sass/Scss stylesheets](https://nextjs.org/docs/pages/building-your-application/styling/sass) are supported without any additional configuration as well. Just import them into [`.storybook/preview.js|ts`](../../configure/index.mdx#configure-story-rendering)
423
+
[Global Sass/Scss stylesheets](https://nextjs.org/docs/pages/building-your-application/styling/sass) are supported without any additional configuration as well. Just import them into [the preview config file](../../configure/index.mdx#configure-story-rendering)
424
424
425
-
```js title=".storybook/preview.js|ts"
426
-
import'../styles/globals.scss';
427
-
```
425
+
{/* prettier-ignore-start */}
428
426
429
-
This will automatically include any of your [custom Sass configurations](https://nextjs.org/docs/pages/building-your-application/styling/sass#customizing-sass-options) in your `next.config.js` file.
This will automatically include any of your [custom Sass configurations](https://nextjs.org/docs/pages/building-your-application/styling/sass#customizing-sass-options) in your Next.js config file.
The built in CSS-in-JS solution for Next.js is [styled-jsx](https://nextjs.org/docs/pages/building-your-application/styling/css-in-js), and this framework supports that out of the box too, zero config.
You can use your own babel config too. This is an example of how you can customize styled-jsx.
499
460
@@ -513,11 +474,20 @@ You can use your own babel config too. This is an example of how you can customi
513
474
}
514
475
```
515
476
516
-
#### PostCSS
477
+
###Tailwind
517
478
518
-
Next.js lets you [customize PostCSS config](https://nextjs.org/docs/pages/building-your-application/configuring/post-css). Thus this framework will automatically handle your PostCSS config for you.
479
+
Tailwind in Next.js [is supported via PostCSS](https://nextjs.org/docs/app/getting-started/css#tailwind-css). Storybook will automatically handle the PostCSS config for you, including any custom PostCSS configuration,
480
+
so you can just import your global CSS directly into [the preview config file](../../configure/index.mdx#configure-story-rendering):
481
+
482
+
{/* prettier-ignore-start */}
519
483
520
-
This allows for cool things like zero-config Tailwind! (See [Next.js' example](https://github.com/vercel/next.js/tree/canary/packages/create-next-app/templates/default-tw))
484
+
<CodeSnippetspath="nextjs-styling-tailwind.md" />
485
+
486
+
{/* prettier-ignore-end */}
487
+
488
+
### PostCSS
489
+
490
+
Next.js lets you [customize PostCSS config](https://nextjs.org/docs/pages/building-your-application/configuring/post-css). Thus this framework will automatically handle your PostCSS config for you.
0 commit comments