Skip to content

How to make the background of the Scrollbar consistent with the width of the grabbed element #8895

Closed

Description

@uyue51

Version/Branch of Dear ImGui:

Version 1.90.9, Branch: master (master/docking/etc.)

Back-ends:

imgui_impl_dx11.cpp + imgui_impl_dx11.cpp

Compiler, OS:

Windows10

Full config/build information:

No response

Details:

I want the background of the scroll bar to be consistent with the width of the grabbed element, but the grabbed element is always a little thinner than the background of the scroll bar

Screenshots/Video:

Image

Minimal, Complete and Verifiable Example code:

void SetGlobalScrollbarStyle()
{
if (!ImGui::GetCurrentContext()) {
return;
}

ImGuiStyle& style = ImGui::GetStyle();

const float scrollbar_width = 6.0f;
style.ScrollbarSize = scrollbar_width;

style.ScrollbarRounding = 0.0f;
style.GrabRounding = 0.0f;

style.Colors[ImGuiCol_ScrollbarBg] = ImVec4(0.18f, 0.18f, 0.18f, 1.00f);
style.Colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.28f, 0.28f, 0.28f, 1.00f);
style.Colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.35f, 0.35f, 0.35f, 1.00f);
style.Colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.25f, 0.25f, 0.25f, 1.00f);

}

Activity

  1. ocornut commented on Aug 20, 2025

    @ocornut
    Owner

    This has been hardcoded until now.

    I have just pushed a new style.ScrollbarPadding setting to adjust it : 42656b3

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      ⌂ 换网址