Log-in required.

You are trying to access the internal Editor Foundations design system.
Sign-in with your Unity Google account to continue, or visit the public site.

Implementation references

Scripting API and implementation references.

UI Toolkit
IMGUI

Overview

Scroll view with a vertical scrollbar in project window in dark and light themes

Editor contains four types of search fields:

  • Scroll view is a view container that allows the scrolling and zooming of its contained views
  • It allows the display of content that is larger than the containing view
  • It clips the content to its frame which can be adjusted to match the containing viewport

Scroll view APIs

Scroll views can have horizontal and vertical scrollbars

Scroll view in UI Toolkit

Slider icon
UI Builder allows visual creation of UI assets in UI Toolkit, and is available as a built-in feature {2021.1 and later} or a package {2020.3 and earlier}
UI Toolkit
ScrollView
Makes a scrollable frame
Scroll view in IMGUI
IMGUI
EditorGUILayout
.BeginScrollView
Begin an automatically laid out scrollview
EditorGUILayout
.EndScrollView
Ends a scrollview started with a call to BeginScrollView

Guidance

When to use

  • Scroll view is a container control that enables scrolling in the window, when content is larger than the viewport
  • Place your content in a scroll view when your window has limited viewport space (e.g., long list / tree views or modals)
  • Scroll views can have vertical and horizontal scrollbars

Container and viewport

An annotated diagram of a foldout header and foldout contents
Scroll view displaying content viewport and content container
Content container

In the UI Toolkit framework, contentContainer represents the entire content area, and can potentially be partially visible.

Content viewport

In the UI Toolkit framework, contentViewport represents the visible part of contentContainer.

Horizontal and vertical scrollbars

Project window scroll view with both horizontal and vertical scrollbars

Scroll views have different parameters for their scrollbar behavior based on the framework they are used.

Vertical scrollbars
  • In the UI Toolkit framework, use showVertical property to display a vertical scrollbar
  • In IMGUI framework, use alwayShowVertical property to always display a vertical scrollbar
Horizontal scrollbars
  • In the UI Toolkit framework, use showHorizontal property to display a horizontal scrollbar
  • In IMGUI framework, use alwayShowHorizontal property to always display a horizontal scrollbar

Scrolling speed

In the UI Toolkit framework, scrolling speed can be adjusted by changing the page size property.

Vertical scroller speed
  • In the UI Toolkit framework, change verticalPageSize value to control the scrolling speed of the vertical scroller
Horizontal scroller speed
  • In the UI Toolkit framework, change horizontalPageSize value to control the scrolling speed of the vertical scroller

Elasticity

In the UI Toolkit framework, the amount of elasticity to use when a user tries to scroll past the boundaries of the scroll view can be adjusted by using the elasticity property.

Formatting

Anatomy and layout

Anatomy
Anatomy of a scroll view and its key parts

1. Scrollbar button
2. Scrollbar groove
3. Scrollbar thumb
4. Content container
5. Content viewport

Color

Scrollbar button shown in hover state
Scrollbar Button Background
--unity-colors-scrollbar_button-background
The background color for a scrollbar's scroll buttons
rgba(0, 0, 0, 0.05098039)
rgba(0, 0, 0, 0.05098039)
Scrollbar Button Background Hover
--unity-colors-scrollbar_button-background-hover
The background color for a scrollbar's scroll buttons when the mouse pointer hovers over them
#A7A7A7
#494949
Scrollbar Groove Background
--unity-colors-scrollbar_groove-background
The background color for a scrollbar's groove (background)
rgba(0, 0, 0, 0.05098039)
rgba(0, 0, 0, 0.05098039)
Scrollbar Groove Border
--unity-colors-scrollbar_groove-border
The border color for a scrollbar's groove
rgba(0, 0, 0, 0.1019608)
rgba(0, 0, 0, 0.1019608)
Scrollbar Thumb Background
--unity-colors-scrollbar_thumb-background
The background color for a scrollbar's thumb/handle
#9A9A9A
#5F5F5F
Scrollbar Thumb Background Hover
--unity-colors-scrollbar_thumb-background-hover
The background color for a scrollbar's thumb/handle when the mouse pointer hovers over it
#8E8E8E
#686868
Scrollbar Thumb Border
--unity-colors-scrollbar_thumb-border
The border color for a scrollbar's thumb/handle
#B9B9B9
#323232
Scrollbar Thumb Border Hover
--unity-colors-scrollbar_thumb-border-hover
The border color for a scrollbar's thumb/handle when the mouse pointer hovers over it
#8E8E8E
#686868

Code samples