Skip to content

feat(components): base ScrollArea on RekaUI ScrollArea component#6140

Open
mikenewbon wants to merge 2 commits intonuxt:v4from
mikenewbon:v4
Open

feat(components): base ScrollArea on RekaUI ScrollArea component#6140
mikenewbon wants to merge 2 commits intonuxt:v4from
mikenewbon:v4

Conversation

@mikenewbon
Copy link
Contributor

#6139

❓ 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

As mentioned here, we should base ScrollArea off the Reka example for proper accessibility and styling on the scroll/thumb.
#5201 (comment)

📝 Checklist

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

@github-actions github-actions bot added the v4 #4488 label Mar 2, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 2, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2c743c4 and 3938654.

⛔ Files ignored due to path filters (2)
  • test/components/__snapshots__/ScrollArea-vue.spec.ts.snap is excluded by !**/*.snap
  • test/components/__snapshots__/ScrollArea.spec.ts.snap is excluded by !**/*.snap
📒 Files selected for processing (2)
  • docs/content/docs/2.components/scroll-area.md
  • test/components/ScrollArea.spec.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • test/components/ScrollArea.spec.ts

📝 Walkthrough

Walkthrough

Replaces the previous primitive-based ScrollArea with reka-ui's ScrollAreaRoot, ScrollAreaViewport, ScrollAreaScrollbar, ScrollAreaThumb, and ScrollAreaCorner; adds type and scrollHideDelay props (forwarded from ScrollAreaRoot) and exposes viewport, scrollTop(), and scrollTopLeft() alongside the virtualizer. Adjusts virtualizer to use the viewport element and updates virtual item styling (lanes, gaps, RTL). Theme defaults changed (root overflow handling) and new slots added: scrollbar, thumb, corner. Documentation for ScrollArea and tests were added/extended to cover new props and UI slot options. No runtime logic unrelated to these integrations was introduced.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: basing the ScrollArea component on RekaUI's ScrollArea component.
Description check ✅ Passed The description clearly references the related issue, explains the rationale for the change (accessibility and styling improvements), and confirms documentation was updated.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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
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.

🧹 Nitpick comments (3)
src/runtime/components/ScrollArea.vue (1)

270-275: Consider extracting a single viewport getter for both exposed aliases.

$el and viewport currently duplicate the same lookup/cast. A shared getter would reduce drift risk.

♻️ Optional cleanup
+const getViewportElement = () => rootRef.value?.viewport as HTMLElement | undefined
+
 defineExpose({
   get $el() {
-    return rootRef.value?.viewport as HTMLElement | undefined
+    return getViewportElement()
   },
   get viewport() {
-    return rootRef.value?.viewport as HTMLElement | undefined
+    return getViewportElement()
   },
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/runtime/components/ScrollArea.vue` around lines 270 - 275, Both $el and
viewport duplicate the same lookup/cast from rootRef.value?.viewport; extract a
single shared getter (e.g., a private computed or function like getViewport or
viewportEl) that returns rootRef.value?.viewport as HTMLElement | undefined and
have the existing getters $el and viewport simply return that single getter;
update references in the component to use the new shared getter name and remove
the duplicated casting logic from $el and viewport.
docs/content/docs/2.components/scroll-area.md (1)

245-247: Include corner in the UI customization note for completeness.

This note currently mentions scrollbar and thumb, but corner is also now customizable in this PR.

📝 Suggested doc tweak
- The scrollbar appearance can be customized via the `ui` prop using the `scrollbar` and `thumb` slots.
+ The scrollbar appearance can be customized via the `ui` prop using the `scrollbar`, `thumb`, and `corner` slots.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/content/docs/2.components/scroll-area.md` around lines 245 - 247, Update
the docs note about ScrollArea UI customization to list the new `corner` slot
alongside `scrollbar` and `thumb`; specifically, edit the sentence that
currently reads "The scrollbar appearance can be customized via the `ui` prop
using the `scrollbar` and `thumb` slots." to include `corner` (e.g.,
"`scrollbar`, `thumb`, and `corner` slots") so the `ui` prop customization
description and references to slots (scrollbar, thumb, corner) are accurate for
the ScrollArea component.
test/components/ScrollArea.spec.ts (1)

28-35: Add a type: 'glimpse' render case to complete the variant matrix.

You already cover auto/always/scroll/hover; adding glimpse would align tests with the documented prop options.

✅ Suggested test case
     ['with type auto', { props: { ...props, type: 'auto' } }],
     ['with type always', { props: { ...props, type: 'always' } }],
     ['with type scroll', { props: { ...props, type: 'scroll' } }],
     ['with type hover', { props: { ...props, type: 'hover' } }],
+    ['with type glimpse', { props: { ...props, type: 'glimpse' } }],
     ['with scrollHideDelay', { props: { ...props, type: 'scroll', scrollHideDelay: 1000 } }],
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/components/ScrollArea.spec.ts` around lines 28 - 35, Add a new test case
entry to the existing test cases array in ScrollArea.spec.ts to cover the
missing "glimpse" variant: create an entry like ['with type glimpse', { props: {
...props, type: 'glimpse' } }] alongside the other type cases (the array that
currently includes 'with type auto', 'with type always', 'with type scroll',
'with type hover'); ensure it uses the same props spread pattern and naming
convention so the render matrix includes the documented type option.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@docs/content/docs/2.components/scroll-area.md`:
- Around line 245-247: Update the docs note about ScrollArea UI customization to
list the new `corner` slot alongside `scrollbar` and `thumb`; specifically, edit
the sentence that currently reads "The scrollbar appearance can be customized
via the `ui` prop using the `scrollbar` and `thumb` slots." to include `corner`
(e.g., "`scrollbar`, `thumb`, and `corner` slots") so the `ui` prop
customization description and references to slots (scrollbar, thumb, corner) are
accurate for the ScrollArea component.

In `@src/runtime/components/ScrollArea.vue`:
- Around line 270-275: Both $el and viewport duplicate the same lookup/cast from
rootRef.value?.viewport; extract a single shared getter (e.g., a private
computed or function like getViewport or viewportEl) that returns
rootRef.value?.viewport as HTMLElement | undefined and have the existing getters
$el and viewport simply return that single getter; update references in the
component to use the new shared getter name and remove the duplicated casting
logic from $el and viewport.

In `@test/components/ScrollArea.spec.ts`:
- Around line 28-35: Add a new test case entry to the existing test cases array
in ScrollArea.spec.ts to cover the missing "glimpse" variant: create an entry
like ['with type glimpse', { props: { ...props, type: 'glimpse' } }] alongside
the other type cases (the array that currently includes 'with type auto', 'with
type always', 'with type scroll', 'with type hover'); ensure it uses the same
props spread pattern and naming convention so the render matrix includes the
documented type option.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 390060c and 2c743c4.

⛔ Files ignored due to path filters (2)
  • test/components/__snapshots__/ScrollArea-vue.spec.ts.snap is excluded by !**/*.snap
  • test/components/__snapshots__/ScrollArea.spec.ts.snap is excluded by !**/*.snap
📒 Files selected for processing (4)
  • docs/content/docs/2.components/scroll-area.md
  • src/runtime/components/ScrollArea.vue
  • src/theme/scroll-area.ts
  • test/components/ScrollArea.spec.ts

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 2, 2026

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

commit: c81d14b

@benjamincanac
Copy link
Member

@mikenewbon I'm not sure this is the right move, the Reka UI ScrollArea component is meant to augment native scroll functionality. This is not what we're doing here 🤔

@mikenewbon
Copy link
Contributor Author

@benjamincanac This suddenly jumped on my priority list after seeing my app on a windows laptop and wanting nice scrollbars. Basing this off Reka seemed like a double win for accessibility. Could also look at implementing it myself, wdyt?

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.

2 participants