Skip to content

Add mouseCursor property to RawScrollbar and ScrollbarThemeData #185733

Closed

Description

@ds-vitaliise

Use case

When a multiline TextField displays a scrollbar, the mouse cursor remains as an I-beam (text cursor) when hovering over the scrollbar thumb and track. Users expect the cursor to change to a default arrow pointer when hovering over a scrollbar, matching native platform behavior on desktop and web.

The root cause is in RawScrollbarState.build() (scrollbar.dart, line 2235): the MouseRegion wrapping the scrollbar content has no cursor parameter, defaulting to MouseCursor.defer. This defers cursor resolution to the parent widget — in the case of TextField, that parent is a MouseRegion(cursor: SystemMouseCursors.text) (text_field.dart, line 1785), which covers the entire widget including the scrollbar zone.

The scrollbar has no separate hit-test target — it is painted via CustomPaint.foregroundPainter on top of the child content. Because Flutter's cursor resolution picks the first non-defer MouseRegion in hit-test order (inner to outer, mouse_cursor.dart, line 262), there is no way for consumers to override the cursor specifically for the scrollbar area without subclassing and forking the entire RawScrollbarState.build() method.

Alternatives considered:

We tested 8 workaround approaches including ScrollBehavior wrappers, custom RawScrollbar subclasses, Stack overlays, TextField.mouseCursor overrides, and direct DOM cursor manipulation (for Flutter web/CanvasKit). All fail because:

  • External wrappers are outer to TextField's MouseRegion in the widget tree, so they lose cursor resolution
  • Internal wrappers (via ScrollBehavior.buildScrollbar) only cover the content area, not the TextField padding zone where the scrollbar is visually rendered
  • TextField.mouseCursor override changes cursor for both the text area and scrollbar — losing the I-beam for text editing

Full investigation with POC code: https://github.com/ds-vitse/spike-scrollbar-cursor-ligui-3465

No major Flutter UI library has solved this (checked: fluent_ui, macos_ui, shadcn_flutter — all extend RawScrollbar and inherit the same limitation).

Related issues: #58192 (add mouse cursor support to remaining widgets), #88371 (themable mouse cursors)

Proposal

Add a mouseCursor property to RawScrollbar and ScrollbarThemeData, similar to how other interactive widgets expose cursor customization.

Minimal change in RawScrollbarState.build() at scrollbar.dart, line 2235:

// Current:
child: MouseRegion(
  onExit: ...
  onHover: ...

// Proposed:
child: MouseRegion(
  cursor: widget.mouseCursor ?? MouseCursor.defer,
  onExit: ...
  onHover: ...

Additionally, ScrollbarThemeData should support a mouseCursor property (consistent with #88371), and the Material Scrollbar should resolve it from the theme.

An ideal implementation would use isPointerOverScrollbar() to apply the cursor only when the pointer is over the scrollbar track/thumb, not the entire content area — keeping the parent widget's cursor (e.g. I-beam for TextField) for the content area.

Flutter version: 3.35.7 (Dart 3.9.2), verified against master branch source.

Activity

  1. added 3 commits that reference this issue on Apr 29, 2026
    f286ac9
    cc9af79
    446e9bd
  2. added
    c: proposalA detailed proposal for a change to Flutter
    c: new featureNothing broken; request for a new capability
    frameworkflutter/packages/flutter repository. See also f: labels.
    f: scrollingViewports, list views, slivers, etc.
    on Apr 29, 2026
  3. vitamin33 commented on Apr 30, 2026

    @vitamin33

    Closed in favor of #185811 with a simplified description.

  4. vitamin33 commented on Apr 30, 2026

    @vitamin33

    Closing in favor of #185811 with a simplified description and screen recording.

  5. ds-vitaliise commented on Apr 30, 2026

    @ds-vitaliise
    Author

    Duplicate of #185813

  6. github-actions commented on May 14, 2026

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  7. locked as resolved and limited conversation to collaborators on May 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    c: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Flutterf: scrollingViewports, list views, slivers, etc.frameworkflutter/packages/flutter repository. See also f: labels.team-frameworkOwned by Framework team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions