- style
Scrollbar
- 1 Description
- 2 Types
- 3 Usage & Behavior
- 3.1 General guidelines
- 3.1.1 Placement and positioning
- 3.1.2 Default state
- 3.1.3 Content
- 3.2 States
- 3.3 Interaction
- 3.4 Best practices
- 3.1 General guidelines
- 4 Accessibility compliance
- 5 Design
- 6 Code
Description
A Scrollbar allows the controlled reveal of extra content which would otherwise not fit within the allocated UI area. Scrollbars can be used within containers of the page layout and also within individual components.
Types
Type | Usage |
---|---|
Fixed Scrollbar | When a fixed amount of content is loaded into a container or component that is not large enough to display it all at once, a horizontal or vertical scrollbar enables the remaining content to be moved into view. |
Infinite Scrollbar | When a large undefined amount of content is available for a container or component that is not large enough to display it all at once, a horizontal or vertical scrollbar enables more content to be dynamically loaded into view. |
Choose the appropriate type according to the amount of content you need to display and the content area available.
Usage & Behavior
Currently only webkit based web browsers (such as Chrome & Safari) fully support native scrollbar custom styling to the degree required to conform to our visual design guidelines. It is therefore recommended to leave all non-webkit browsers at their native scrollbar visual design language (using the CSS Overflow property) in order to aid consistency in behavior and accessibility, rather than attempting to re-implement scrollbars across each environment. Our implementation below follows this recommendation.
General guidelines
Placement and positioning
Always offer a scrollbar if an area has scrolling content. Don't rely on auto-scrolling or on dragging, as users may not realise it's an option. The scrollbar provides a visual clue that more content is available.
Hide scrollbars entirely if all content is visible. If users see a scrollbar, they will assume there's additional content and be frustrated if they can't scroll.
Default state
Comply with the default operating system standards in order to maintain platform familiarity. All default browser scroll behaviors should be enabled by default. Operating system and browser defaults such as scroll inertia, scroll wheel support, gesture support, and any OS user customisations should all behave as factory designed.
Content
Display all important information above the fold. Users often decide whether to continue or leave based on what they can see without scrolling.
States
There are no focused or disabled states for scrollbars as these states are handled by the parent component.
State | Scroll |
---|---|
Regular Vertical | |
Hover Vertical | |
Active Vertical | |
Regular Horizontal | |
Hover Horizontal | |
Active Horizontal |
Interaction
Scroll interaction is governed by the device, operating system, and browser being used. The default interaction behaviors shouldn't be changed, primarily for conformance and accessibility reasons. The following are the required interaction recommendations common to all.
Input device | Discrete scroll | Continuous scroll |
---|---|---|
Keyboard |
|
|
Mouse |
|
|
Trackpad |
|
|
Best practices
Avoid scrolling within scrolling.
Make sure the browser back button works properly in regard to saving the scrollbar position.
Avoid scroll hijacking. Applications that implement scroll hijacking take control of the scroll and override a basic function of the web browser.
Use sticky navigation. Long scrolling can make navigation problematic. If the user loses visibility of the navigation menu (for the container, table etc.) when they scroll down, they will have to scroll all the way back to the top to perform an action. Instead, use a sticky (persistently visible) navigation menu to make moving around the app fast and easy.
Avoid horizontal scrolling when possible.
Provide visual feedback when loading new content. When using infinite scroll, it needs to be clear to the user that content is being dynamically loaded. Use a Progress Indicator to show that new content will soon appear on the page.
Accessibility compliance
Unless otherwise specified, see our general compliance information in Fundamentals - Accessibility.
Focus management
The scrollbar component itself cannot be focused via the keyboard. Instead, it’s derived from the focus of the page components. Please see the Keyboard & Focus Management Guidelines to ensure that scrollable content areas are properly supported.
Assistive scrolling bindings vary with device, operating system, and browser. Nevertheless, the key bindings described in the Scroll#Interaction section above should be supported as a minimum.
Screen reader support
As it's recommended to use the native browser scrollbar component, screen reader support is already built in. Users are notified about scrollbars when they encounter a scrollable area with the 'overflow' property defined as 'auto' or 'scroll'. Make sure the scrollable area itself also supports screen readers where needed - see the Screen Reader Guidelines.
Design
Zeplin link | Screen thumbnail |
---|---|
Code
A scrollbar is enabled by applying the appropriate CSS Overflow property value to a content area.