-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Docs: Make Next.js Tailwind instructions more explicit for default globals.css #28625
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
- Updated
docs/get-started/frameworks/nextjs.mdxto include explicit instructions for importing global Tailwind styles. - Clarified integration steps for Tailwind CSS with Storybook in a Next.js project.
1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings
|
@jonniebigodes, can you please take a look? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your PR @gpoole! Considering how ubiquitious Tailwind is these days, I agree it'd help to show such a small snippet to get people started.
I'm requesting changes so the code example can be moved into a snippet for easier maintenance.
If you're up for it, you could make a few other improvements:
- fix a few other snippets on that page that mix up TS and JS
- add a "Next.js styling" heading to encompass all the styling options
- maybe have a dedicated Tailwind section for visibility above PostCSS?
- This could then allow the PostCSS section to explain that the framework will honour Next.js PostCSS config out of the box
(@jonniebigodes please let me know if you disagree to any of the above suggestions!)
| For Tailwind, import your global CSS into [`.storybook/preview.js|ts`](../../configure/index.mdx#configure-story-rendering): | ||
|
|
||
| ```js | ||
| // .storybook/preview.js|ts | ||
| import '../app/globals.css'; | ||
| ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This example should be embedded in a code snippet: https://storybook.js.org/docs/contribute/documentation/new-snippets.
This allows you to both show TS and JS examples (we usually at least want these two), and to show the filename being edited. You could then reword "[.storybook/preview.js|ts]" to say "preview config file" as it would be redundant with the immediate snippet under it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Sidnioulz, your suggestion is on point. With that in mind, @gpoole, are you okay with following up on this pull request and incorporating @Sidnioulz 's feedback so that we can make this available in the documentation? Let me know, and we'll go from there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure I'll take a look 👍
WalkthroughThis PR updates Next.js documentation by adding multiple reusable code snippets and restructuring the styling section. New snippets cover CSS Modules (JS/TS Button components), Sass configuration in next.config (JS/TS), Storybook preview imports for Sass and Tailwind (JS/TS), and a styled-jsx component (JS/TS). The Next.js guide (docs/get-started/frameworks/nextjs.mdx) is reorganized under “Next.js Styling,” replacing inline examples with CodeSnippets references and introducing/renaming subsections for Sass/Scss, CSS Modules, Styled JSX, and Tailwind. No runtime code changes; modifications are limited to docs. Suggested labels
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches🧪 Generate unit tests
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
docs/_snippets/nextjs-styling-tailwind.md (1)
1-7: Cover projects that opt into thesrc/directory
Many projects say “yes” whencreate-next-appasks about thesrc/directory. In that case this import path breaks. Let’s call out the alternate path right in the snippet.Apply this diff to note the
src/directory variant:```js filename=".storybook/preview.js" renderer="nextjs" language="js" tabTitle="JavaScript" import '../app/globals.css'; +// If you enabled Next.js' optional `src/` directory, use `../src/app/globals.css` instead.import '../app/globals.css'; +// If you enabled Next.js' optional `src/` directory, use `../src/app/globals.css` instead.</blockquote></details> </blockquote></details> <details> <summary>📜 Review details</summary> **Configuration used**: CodeRabbit UI **Review profile**: CHILL **Plan**: Pro <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between ab386d77a4de696c360e061ce3781fcb43801e62 and 8f458ed6aad5f72528480d2a1ba38f1bc817de54. </details> <details> <summary>📒 Files selected for processing (6)</summary> * `docs/_snippets/nextjs-styling-css-modules.md` (1 hunks) * `docs/_snippets/nextjs-styling-sass-config.md` (1 hunks) * `docs/_snippets/nextjs-styling-sass-preview.md` (1 hunks) * `docs/_snippets/nextjs-styling-styled-jsx-component.md` (1 hunks) * `docs/_snippets/nextjs-styling-tailwind.md` (1 hunks) * `docs/get-started/frameworks/nextjs.mdx` (2 hunks) </details> <details> <summary>🔇 Additional comments (4)</summary><blockquote> <details> <summary>docs/_snippets/nextjs-styling-sass-preview.md (1)</summary><blockquote> `1-7`: **Clear Sass preview import example** Nice job surfacing both JS and TS preview imports for the default Sass globals setup. This will save folks a trip to the Next.js starter to double-check the path. </blockquote></details> <details> <summary>docs/_snippets/nextjs-styling-css-modules.md (1)</summary><blockquote> `1-31`: **Polished CSS Modules snippet** Highlighting the Storybook-friendly import plus the Sass variations in both JS and TS flavors is exactly the kind of clarity our readers need. </blockquote></details> <details> <summary>docs/_snippets/nextjs-styling-styled-jsx-component.md (1)</summary><blockquote> `1-63`: **Comprehensive styled-jsx example** Great coverage of scoped, global, and responsive styles in both JS and TS snippets—readers get the full picture. </blockquote></details> <details> <summary>docs/get-started/frameworks/nextjs.mdx (1)</summary><blockquote> `434-502`: **Styling section reorg reads well** The new “Next.js Styling” layout with CodeSnippets makes the page far easier to scan, and the Tailwind callout directly addresses a common setup pain point. </blockquote></details> </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
…ding Tailwind example
|
Apologies for the noisy pushes on this change, I probably should have just started over. Preview looks ok to me, @Sidnioulz could you please check if this is what you were after? I've avoided touching anything outside of the styles or I think the change could get a bit beyond what I was doing originally with the PR. |
Sidnioulz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fantastic work, thank you so much @gpoole!
@jonniebigodes there are only a bunch of CJS/ESM changes to make, I've added GH suggestions. I'm letting you merge this once you've had time to review/apply them :)
|
View your CI Pipeline Execution ↗ for commit 3f1fa49
☁️ Nx Cloud last updated this comment at |
jonniebigodes
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gpoole, sorry for the delayed response on this pull request, as I've been tasked with other documentation changes that required my attention. However, I've had time to check this, and it looks good on my end.
I will merge this once the checklist is cleared.
Hope you have a fantastic week.
Stay safe
What I did
Update the documentation to explicitly show how to import global Tailwind styles that are created automatically by the Next.js app generator if users select "Tailwind" as their preferred styling system.
Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!
Documentation
MIGRATION.MD
Checklist for Maintainers
When this PR is ready for testing, make sure to add
ci:normal,ci:mergedorci:dailyGH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found incode/lib/cli/src/sandbox-templates.tsMake sure this PR contains one of the labels below:
Available labels
bug: Internal changes that fixes incorrect behavior.maintenance: User-facing maintenance tasks.dependencies: Upgrading (sometimes downgrading) dependencies.build: Internal-facing build tooling & test updates. Will not show up in release changelog.cleanup: Minor cleanup style change. Will not show up in release changelog.documentation: Documentation only changes. Will not show up in release changelog.feature request: Introducing a new feature.BREAKING CHANGE: Changes that break compatibility in some way with current major version.other: Changes that don't fit in the above categories.🦋 Canary release
This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the
@storybookjs/coreteam here.core team members can create a canary release here or locally with
gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=<PR_NUMBER>Summary by CodeRabbit