::scroll-button() CSS Pseudo Element
Description
The ::scroll-button() pseudo-element represents an interactive control that allows users to scroll a container in a specific direction (such as up, down, left, or right). It is part of the emerging CSS Scroll Buttons concept, designed to give authors native, stylable scroll controls without relying on JavaScript or custom UI elements. These buttons are conceptually tied to a scroll container and appear only when scrolling in the given direction is possible.
The ::scroll-button() pseudo-element is attached to a scroll container (typically one with overflow set to auto or scroll) and represents directional controls such as up, down, left, or right. Each direction is specified as a functional argument, for example ::scroll-button(down). When rendered, the browser provides a clickable UI element that scrolls the container by a user-agent–defined amount. This approach improves accessibility and consistency compared to manually wiring buttons to JavaScript scroll logic.
Unlike traditional elements such as button, ::scroll-button() is not part of the DOM tree. Instead, it behaves similarly to other UI pseudo-elements, allowing authors to style it visually while the browser controls its behavior. You can influence its appearance using standard CSS properties such as background-color, border-radius, padding, and opacity. However, layout-affecting properties like position or display may be restricted depending on the implementation.
The ::scroll-button() pseudo-element is especially useful for custom scroll experiences, such as horizontal card scrollers, carousels, or code blocks with overflow. Because the browser manages the scrolling behavior, it automatically respects user input methods (mouse, keyboard, touch, accessibility tools) without additional scripting. This makes it more robust and accessible than manually implemented scrolling buttons.
Example
.scroll-box {
width: 300px;
height: 150px;
overflow: auto;
border: 1px solid #ccc;
}
/* Style the downward scroll button */
.scroll-box::scroll-button(down) {
background-color: #007acc;
color: white;
padding: 6px;
border-radius: 6px;
opacity: 0.8;
}
.scroll-box::scroll-button(down):hover {
opacity: 1;
}
<div class="scroll-box">
<p>Scrollable content...</p>
<p>More content...</p>
<p>Even more content...</p>
</div>
In this example, the downward scroll button appears only when additional content exists below the visible area. The browser determines placement and behavior, while CSS controls the visual styling. As support evolves, ::scroll-button() is expected to play an important role in building native-feeling, accessible scrolling interfaces without JavaScript dependencies.
Syntax
::scroll-button(<scroll-button-direction>) {
/* ... */
}
Values
- <scroll-button-direction>
The value inside the parentheses defines which button you are targeting. You can use the following keywords:
up: Targets the button used to scroll upwards.down: Targets the button used to scroll downwards.left: Targets the button used to scroll to the left.right: Targets the button used to scroll to the right.block-start: Targets the button at the start of the block axis (top in a standard horizontal-TB layout).block-end: Targets the button at the end of the block axis (bottom).inline-start: Targets the button at the start of the inline axis (left in LTR layouts).inline-end: Targets the button at the end of the inline axis (right in LTR layouts).
Example
Browser Support
The following information will show you the current browser support for the CSS ::scroll-button() pseudo element. Hover over a browser icon to see the version that first introduced support for this CSS psuedo element.
This psuedo element is supported in some modern browsers, but not all.
Desktop
Tablets & Mobile
Last updated by CSSPortal on: 31st December 2025
