Skip to content

feat(Sidebar): add transition prop#6484

Open
benjamincanac wants to merge 1 commit into
v4from
feat/sidebar-transition
Open

feat(Sidebar): add transition prop#6484
benjamincanac wants to merge 1 commit into
v4from
feat/sidebar-transition

Conversation

@benjamincanac
Copy link
Copy Markdown
Member

🔗 Linked issue

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

Add a transition prop to USidebar (defaults to true) thate collapse/expand animation. Follows the same pattern as UModal's transition prop.

  • Move transition classes from base theme slots into a transition: true variant
  • Switch easing from ease-linear to ease-out for a more natural feel

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@github-actions github-actions Bot added the v4 #4488 label May 22, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 22, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

The PR introduces conditional transition styling to the Sidebar component. A new optional transition prop (defaulting to true) is added to the SidebarProps interface and wired through the component's withDefaults and ui configuration. The sidebar theme configuration is updated to remove unconditional transition utilities from slot classes and instead conditionally apply them only when the transition option is enabled, with specific transitions for width, position, and color changes across the gap, container, and rail slots.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding a transition prop to the Sidebar component.
Description check ✅ Passed The description is directly related to the changeset, providing context about the new transition prop, implementation approach, and design rationale.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/sidebar-transition

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

src/runtime/components/Sidebar.vue

Parsing error: Unexpected token )

src/theme/sidebar.ts

Parsing error: Unexpected token {


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a 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

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/theme/sidebar.ts`:
- Around line 20-26: The transition: true variant in src/theme/sidebar.ts
currently unconditionally adds animation classes; update the variant generation
to respect the global options.theme.transitions toggle by returning no
transition classes (or an empty/disabled variant) when options.theme.transitions
is false. Locate the transition: { true: { ... } } entry and change its
implementation to check options.theme.transitions (the global toggle) and only
include gap/container/rail classes when that flag is true, otherwise omit or
return empty strings so animations are effectively disabled.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5647cd1a-f5d5-4d39-9152-5e19bc6abbb1

📥 Commits

Reviewing files that changed from the base of the PR and between 09f9cd0 and e8de2ad.

⛔ Files ignored due to path filters (2)
  • test/components/__snapshots__/Sidebar-vue.spec.ts.snap is excluded by !**/*.snap
  • test/components/__snapshots__/Sidebar.spec.ts.snap is excluded by !**/*.snap
📒 Files selected for processing (2)
  • src/runtime/components/Sidebar.vue
  • src/theme/sidebar.ts

Comment thread src/theme/sidebar.ts
Comment on lines +20 to +26
transition: {
true: {
gap: 'transition-[width] duration-200 ease-out',
container: 'transition-[left,right,width] duration-200 ease-out',
rail: 'transition-all ease-out'
}
},
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot May 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Honor the global options.theme.transitions toggle in the new variant.

transition: true currently adds animation classes even when options.theme.transitions is false, so global motion disabling is bypassed.

Suggested fix
   variants: {
     transition: {
-      true: {
-        gap: 'transition-[width] duration-200 ease-out',
-        container: 'transition-[left,right,width] duration-200 ease-out',
-        rail: 'transition-all ease-out'
-      }
+      true: options.theme.transitions ? {
+        gap: 'transition-[width] duration-200 ease-out',
+        container: 'transition-[left,right,width] duration-200 ease-out',
+        rail: 'transition-all ease-out'
+      } : {}
     },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
transition: {
true: {
gap: 'transition-[width] duration-200 ease-out',
container: 'transition-[left,right,width] duration-200 ease-out',
rail: 'transition-all ease-out'
}
},
transition: {
true: options.theme.transitions ? {
gap: 'transition-[width] duration-200 ease-out',
container: 'transition-[left,right,width] duration-200 ease-out',
rail: 'transition-all ease-out'
} : {}
},
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/theme/sidebar.ts` around lines 20 - 26, The transition: true variant in
src/theme/sidebar.ts currently unconditionally adds animation classes; update
the variant generation to respect the global options.theme.transitions toggle by
returning no transition classes (or an empty/disabled variant) when
options.theme.transitions is false. Locate the transition: { true: { ... } }
entry and change its implementation to check options.theme.transitions (the
global toggle) and only include gap/container/rail classes when that flag is
true, otherwise omit or return empty strings so animations are effectively
disabled.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the options.theme.transitions is not for transform animations but for color hovers mostly

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@benjamincanac, thanks for the clarification — that makes perfect sense. options.theme.transitions governs color hover animations (like after:transition-colors on the rail), while the new transition prop is an independent, component-level control for the collapse/expand layout animations (width, left, right). The two are orthogonal, so there's no need to gate the variant behind the global toggle. I was wrong to flag this — apologies for the noise!

(╯°□°)╯ 🐇 ← catching the carrot I threw too early


✏️ Learnings added
Learnt from: benjamincanac
Repo: nuxt/ui PR: 6484
File: src/theme/sidebar.ts:20-26
Timestamp: 2026-05-22T10:49:36.271Z
Learning: In `src/theme/sidebar.ts` (and the Nuxt UI theme system generally), `options.theme.transitions` controls **color hover transitions** (e.g. `after:transition-colors`), NOT layout/transform animations such as `transition-[width]` or `transition-[left,right,width]`. Component-level animation props (e.g. the `transition` prop on `USidebar`) are independent of `options.theme.transitions` and should not be gated behind it.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.


🧠 Learnings used
Learnt from: benjamincanac
Repo: nuxt/ui PR: 6406
File: src/theme/breadcrumb.ts:45-57
Timestamp: 2026-05-05T14:15:14.954Z
Learning: In the Nuxt UI theme code (e.g., `src/theme/breadcrumb.ts` and other theme files), `neutral` should not be expected to appear in `options.theme.colors`. If a change iterates over `options.theme.colors` to generate color variants, do not flag a “duplicate neutral” concern as long as `neutral` is defined only via the explicit variant/color objects (and `neutral` is not part of `options.theme.colors`). As part of the review, verify that `options.theme.colors` does not include `neutral` before suppressing/ignoring any potential duplicate warning.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 22, 2026

npm i https://pkg.pr.new/@nuxt/ui@6484

commit: e8de2ad

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v4 #4488

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant