Docs: Fix UI library examples#33460
Conversation
📝 WalkthroughWalkthroughDocumentation expansion across three files adds multi-framework code examples demonstrating Storybook decorators and context providers. Changes include new Svelte, Web Components, and framework-specific decorator snippets; updates to existing code comments; and replacement of Vue Fontawesome example with Vuetify plus addition of Svelte Bits UI example. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
docs/_snippets/storybook-preview-with-styled-components-decorator.md (1)
243-265: Consider adding duplicate custom element registration check in TypeScript version.The JavaScript version (lines 311-313) properly checks if the custom element is already defined before registering it, preventing duplicate registration errors. The TypeScript version using the
@customElementdecorator doesn't include this check. While the decorator may handle this internally, explicitly checking could prevent issues if the module is imported multiple times.🔎 Suggested addition for defensive registration
If the
@customElementdecorator doesn't automatically handle duplicate registration, consider:+if (!customElements.get('theme-provider')) { @customElement('theme-provider') export class ThemeProvider extends LitElement { // ... rest of class } +}However, if Lit's
@customElementdecorator already handles duplicate registration gracefully, this check is unnecessary.
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
docs/_snippets/decorator-parameterized-in-preview.mddocs/_snippets/storybook-preview-with-styled-components-decorator.mddocs/get-started/setup.mdx
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,jsx,ts,tsx,json,md,html,css,scss}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Format code using Prettier with
yarn prettier --write <file>
Files:
docs/_snippets/storybook-preview-with-styled-components-decorator.mddocs/_snippets/decorator-parameterized-in-preview.md
🧠 Learnings (6)
📓 Common learnings
Learnt from: Sidnioulz
Repo: storybookjs/storybook PR: 32458
File: code/core/src/components/components/Select/Select.tsx:200-204
Timestamp: 2025-11-05T09:38:47.712Z
Learning: Repo: storybookjs/storybook — Guidance: Until Storybook 11 is released, do not suggest using React.useId anywhere (e.g., in code/core/src/components/components/Select/Select.tsx) to maintain compatibility with React 17 runtimes. Prefer advising: accept a caller-provided props.id and, if needed, generate a client-only fallback id to minimize SSR hydration issues — but avoid useId. Resume prompting for useId after Storybook 11.
Learnt from: Sidnioulz
Repo: storybookjs/storybook PR: 32458
File: code/core/src/components/components/Tabs/Tabs.stories.tsx:222-227
Timestamp: 2025-11-05T09:36:55.944Z
Learning: Repo: storybookjs/storybook PR: 32458 — In code/core/src/components/components/Button/Button.tsx (React/TypeScript), ButtonProps includes ariaLabel?: string | false and the component maps it to the DOM aria-label. Convention: ariaLabel is mandatory on all Button usages — provide a descriptive string for icon-only buttons; set ariaLabel=false when the button’s children already serve as the accessible name. Do not suggest using a raw aria-label prop on Button call sites.
Learnt from: Sidnioulz
Repo: storybookjs/storybook PR: 32458
File: code/core/src/components/components/tooltip/WithTooltip.tsx:54-96
Timestamp: 2025-11-05T09:37:25.920Z
Learning: Repo: storybookjs/storybook — In code/core/src/components/components/tooltip/WithTooltip.tsx, the legacy WithTooltip implementation is intentionally reintroduced for backward compatibility and is deprecated; maintainers (per Sidnioulz) do not want maintenance or improvements on it. Prefer WithTooltipNew/Popover; avoid suggesting changes to WithTooltip.* going forward.
Learnt from: ndelangen
Repo: storybookjs/storybook PR: 32507
File: code/core/src/manager/globals/globals-module-info.ts:25-33
Timestamp: 2025-09-24T09:39:39.233Z
Learning: In Storybook, storybook/actions/decorator is a preview-only entrypoint and should not be included in manager globals configuration. The duplicatedKeys array in code/core/src/manager/globals/globals-module-info.ts is specifically for manager-side externalization, not preview entrypoints.
Learnt from: CR
Repo: storybookjs/storybook PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-22T22:03:40.123Z
Learning: Applies to {code/addons,code/frameworks}/**/README.md : Update README files for significant changes and include code examples in addon/framework documentation
📚 Learning: 2025-09-24T09:39:39.233Z
Learnt from: ndelangen
Repo: storybookjs/storybook PR: 32507
File: code/core/src/manager/globals/globals-module-info.ts:25-33
Timestamp: 2025-09-24T09:39:39.233Z
Learning: In Storybook, storybook/actions/decorator is a preview-only entrypoint and should not be included in manager globals configuration. The duplicatedKeys array in code/core/src/manager/globals/globals-module-info.ts is specifically for manager-side externalization, not preview entrypoints.
Applied to files:
docs/_snippets/storybook-preview-with-styled-components-decorator.mddocs/get-started/setup.mdxdocs/_snippets/decorator-parameterized-in-preview.md
📚 Learning: 2025-11-05T09:37:25.920Z
Learnt from: Sidnioulz
Repo: storybookjs/storybook PR: 32458
File: code/core/src/components/components/tooltip/WithTooltip.tsx:54-96
Timestamp: 2025-11-05T09:37:25.920Z
Learning: Repo: storybookjs/storybook — In code/core/src/components/components/tooltip/WithTooltip.tsx, the legacy WithTooltip implementation is intentionally reintroduced for backward compatibility and is deprecated; maintainers (per Sidnioulz) do not want maintenance or improvements on it. Prefer WithTooltipNew/Popover; avoid suggesting changes to WithTooltip.* going forward.
Applied to files:
docs/_snippets/storybook-preview-with-styled-components-decorator.mddocs/get-started/setup.mdxdocs/_snippets/decorator-parameterized-in-preview.md
📚 Learning: 2025-11-05T09:38:47.712Z
Learnt from: Sidnioulz
Repo: storybookjs/storybook PR: 32458
File: code/core/src/components/components/Select/Select.tsx:200-204
Timestamp: 2025-11-05T09:38:47.712Z
Learning: Repo: storybookjs/storybook — Guidance: Until Storybook 11 is released, do not suggest using React.useId anywhere (e.g., in code/core/src/components/components/Select/Select.tsx) to maintain compatibility with React 17 runtimes. Prefer advising: accept a caller-provided props.id and, if needed, generate a client-only fallback id to minimize SSR hydration issues — but avoid useId. Resume prompting for useId after Storybook 11.
Applied to files:
docs/_snippets/storybook-preview-with-styled-components-decorator.mddocs/get-started/setup.mdxdocs/_snippets/decorator-parameterized-in-preview.md
📚 Learning: 2025-12-22T22:03:40.123Z
Learnt from: CR
Repo: storybookjs/storybook PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-22T22:03:40.123Z
Learning: Applies to {code/addons,code/frameworks}/**/README.md : Update README files for significant changes and include code examples in addon/framework documentation
Applied to files:
docs/_snippets/storybook-preview-with-styled-components-decorator.md
📚 Learning: 2025-12-22T22:03:40.123Z
Learnt from: CR
Repo: storybookjs/storybook PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-22T22:03:40.123Z
Learning: Applies to code/{renderers}/**/*.{ts,tsx,js,jsx} : Use `logger` from `storybook/internal/client-logger` for client-side logging in browser code
Applied to files:
docs/_snippets/storybook-preview-with-styled-components-decorator.mddocs/_snippets/decorator-parameterized-in-preview.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Core Unit Tests, windows-latest
🔇 Additional comments (6)
docs/_snippets/decorator-parameterized-in-preview.md (3)
13-13: LGTM! Documentation consistency improvements.The comment updates improve consistency across examples and modernize framework references (e.g.,
react-vite,nextjs-viteinstead of older framework names). These are good documentation maintenance changes.Also applies to: 40-40, 63-63, 75-75, 107-107, 139-139, 170-170, 194-194
285-337: LGTM! Web Components examples follow Lit best practices.The new Web Components examples correctly use Lit's
htmltemplate tag and follow the same decorator pattern as other framework examples. Both TypeScript and JavaScript variants are properly structured.
209-283: No changes needed. The Svelte examples correctly use Svelte 5+ runes syntax ($props(),{@render},Snippettype) which aligns with Storybook's explicit requirement of Svelte 5.0.0 or higher for both svelte-vite and sveltekit frameworks. The concern about older Svelte version compatibility is not applicable, as Storybook no longer supports pre-5 versions. The examples are correct and appropriate for the documented framework requirements.docs/get-started/setup.mdx (1)
69-69: LGTM! Documentation text aligns with new code examples.The updated text correctly references the new Vuetify (Vue) and Bits UI (Svelte) examples added in the companion snippet files, replacing the previous FontAwesome reference. The links and formatting are proper.
docs/_snippets/storybook-preview-with-styled-components-decorator.md (2)
145-221: The Bits UI BitsConfig implementation is correct. UsingBitsConfigwithdefaultPortalTois the documented and recommended approach for configuring portal behavior in Storybook. This ensures Portal-based Bits components (dialogs, tooltips, and other overlay components) render properly in Storybook's iframe. The pattern correctly wraps the story context and sets the portal target, confirming the examples follow best practices.
30-143: The Vue examples correctly demonstrate Vuetify v3 integration. The plugin registration viasetup()and theme switching viav-app :theme="themeName"aligns with Vuetify v3's recommended pattern for per-component theme control. ThethemeNameprop is properly applied through the StoryWrapper component, allowing dynamic theme switching via Storybook globals.
Closes #
What I did
With this pull request, the examples on the Decorators and Setup page were updated to include other frameworks and prevent them from rendering duplicate React examples.
This can be observed currently by navigating to the appropriate documentation and selecting other frameworks (e.g., Svelte)
What was done:
Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
This is a documentation-only change and doesn't require testing
Caution
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-storybook/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 publish.yml --field pr=<PR_NUMBER>Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.