Skip to content

Conversation

@ickshonpe
Copy link
Contributor

@ickshonpe ickshonpe commented Nov 20, 2025

Objective

Draw scrollbars automatically for nodes with scrolled content and a scrollbar_width greater than zero.

Solution

  • New extract_scrollbars system in bevy_ui_render, this automatically renders scrollbars for UI nodes with scrolling content.
  • New component, ScrollbarStyle. For now, it only supports changing the colors.
  • New methods on ComputedNode that compute the geometry for a UI node's scrollbars:
    • horizontal_scrollbar_gutter
    • vertical_scrollbar_gutter
    • horizontal_scrollbar_thumb,
    • vertical_scrollbar_thumb

Testing

cargo run --example scroll

Showcase

Screenshot 2025-11-20 165637

…omatically renders scrollbars for scrolled UI nodes .

* Styling can be set using the new `ScrollbarStyle` component. For now, it only supports changing the scrollbar's colors.

* `ComputedNode` has new methods that can be used to compute the geometry for a UI node's scrollbars:
* `horizontal_scrollbar_gutter`
* `vertical_scrollbar_gutter`
* `horizontal_scrollbar_thumb`,
* `vertical_scrollbar_thumb`
@ickshonpe ickshonpe added A-Rendering Drawing game state to the screen A-UI Graphical user interfaces, styles, layouts, and widgets D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Nov 20, 2025
@ickshonpe ickshonpe added the C-Feature A new feature, making something new possible label Nov 20, 2025
@PPakalns
Copy link
Contributor

PPakalns commented Nov 20, 2025

This is a good improvement for simplifying use of scroll areas.

But still with very small changes in this PR #21836 we can get this functionality out of the box with even allowing bevy users full control over their look, behavior.


I don't think that the approach provided in this PR is the correct one.

  1. This limits scrollbar placement. Some users would like to animate them or even create them in hugely different style.

    For example I have scrollbars that are very thin in this scrollbar_width space. Then they expand over ui node content when mouse interaction happens. That is not possible with this approach.

  2. Modularity and customazibility:

    pub struct ScrollbarStyle {
    /// Color of the scrollbar's thumb
    pub thumb: Color,
    /// Color of the scrollbar's gutter
    pub gutter: Color,
    /// Color of the scrollbar's corner section
    pub corner: Color,
    }

    This approach limits the possible styling of scroll bars and how they are constructed. This approach only supports ui scroll bar styles created by bevy developers. We can not reuse bevy_ui gradients, ImageNodes, ui node hierarchy to create custom scrollbars.

I would like to keep ui scrollbars as customizable as possible. They are important part of ui interfaces in games and requires careful styling. This approach heavily limits that.

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

Labels

A-Rendering Drawing game state to the screen A-UI Graphical user interfaces, styles, layouts, and widgets C-Feature A new feature, making something new possible D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes S-Needs-Review Needs reviewer attention (from anyone!) to move forward

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants