Skip to main content
Elastic UI
Elastic UI
Getting startedComponentsPatternsContentData visualization
EUI ChangelogGitHubFigma
  • Setup
  • Theming
  • Accessibility
  • Testing
  • Utilities
    • Accessibility
    • Auto sizer
    • Color palettes
    • Copy
    • CSS utility classes
    • Delay
    • Error boundary
    • Focus trap
    • Highlight and mark
    • HTML ID generator
    • I18n
    • Inner text
    • Mutation observer
    • Outside click detector
    • Overlay mask
    • Portal
    • Pretty duration
    • Provider
    • Resize observer
    • Scroll
    • Text diff
    • Text truncation
    • Window events
  • EUI
  • Utilities
  • Scroll

Scroll

Scrollable regions must be focusable, promoted to region and with the right aria-label

To ensure keyboard-only users have access to the scrollable regions, the optimal solution is to apply

tabIndex="0" to the region. Learn more about the scrollable-region-focusable rule at Deque.

Scroll bar style

.eui-scrollBar className

Use this utility class to style the browser's scrollbar in a minimal aesthetic. This is best used on small, inner-page contents like panels wherever you have overflow: auto.

โœ„๐˜—
tsx code block:
โœ„๐˜—<div tabIndex={0} className="eui-scrollBar"> <EuiPanel /> <EuiPanel /> <EuiPanel /> </div>

useEuiScrollBar() hook

Use this style function to style the browser's scrollbar in a minimal aesthetic. This is best used on small, inner-page contents like panels.

All parameters are optional and default to specific global settings.

โœ„๐˜—
tsx code block:
โœ„๐˜—css` ${useEuiScrollBar()} `

Vertical (scroll-y)

These utilities allow for quickly applying vertical scrolling to a container. They also automatically apply the minimal scroll bar styles as well. If you do not want your content to stretch to 100% height, you will need to manually add a height (or max-height) to the container.

The WithShadows variants are primarily used in modals and flyouts and masks the edges to indicate there is more content. When using these variants, you may want to add a small amount padding to the top and bottom of your content so the mask doesn't overlay it.

.eui-yScroll className

Quick utility class for adding vertical scrolling to a container.

โœ„๐˜—
tsx code block:
โœ„๐˜—<div tabIndex={0} className="eui-yScrollWithShadows"> <EuiPanel /> <EuiPanel /> <EuiPanel /> </div>

useEuiOverflowScroll('y') hook

Styles hook for adding vertical scrolling to a container.

To mask the top and bottom of the scrolled content, indicating visually that there is more content below, pass in true to the second parameter mask.

useEuiOverflowScroll('y', true);

โœ„๐˜—
tsx code block:
โœ„๐˜—css` ${useEuiOverflowScroll('y', true)} `

Horizontal (scroll-x)

The horizontal equivalent should be used sparingly and usually only in full-height layouts or a grid of items.

When using the WithShadows variant, you may want to add a small amount padding to the sides of your content so the mask doesn't overlay it.

.eui-xScroll className

Quick utility class for adding horizontal scrolling to a container.

โœ„๐˜—
tsx code block:
โœ„๐˜—<div tabIndex={0} className="eui-xScrollWithShadows"> <EuiPanel /> <EuiPanel /> <EuiPanel /> </div>

useEuiOverflowScroll('x') hook

Styles hook for adding horizontal scrolling to a container.

To mask the top and bottom of the scrolled content, indicating visually that there is more content below, pass in true to the second parameter mask.

useEuiOverflowScroll('x', true);

โœ„๐˜—
tsx code block:
โœ„๐˜—css` ${useEuiOverflowScroll('x', true)} `

Full height layout

.eui-fullHeight className

Quick utility for expanding the height of the element to its parents dimensions. Use it to stretch each nested element until the one that applies scroll.

Works on both flex and non-flex elements.

Orbiting this at a distance of roughly ninety-two million miles is an utterly insignificant little blue green planet whose ape-descended life forms are so amazingly primitive that they still think digital watches are a pretty neat idea.

Orbiting this at a distance of roughly ninety-two million miles is an utterly insignificant little blue green planet whose ape-descended life forms are so amazingly primitive that they still think digital watches are a pretty neat idea.

โœ„๐˜—
tsx code block:
โœ„๐˜—<BodyContent style={{ height: 180 }}> <EuiFlexGroup className="eui-fullHeight" responsive={false}> <EuiFlexItem> <BodyScroll className="eui-yScroll" tabIndex={0} /> </EuiFlexItem> <EuiFlexItem> <BodyScroll className="eui-yScroll" tabIndex={0} /> </EuiFlexItem> </EuiFlexGroup> </BodyContent>

euiFullHeight() function

Emotion mixin for adding full height scrolling to a container or flex child.

It applies height: 100%; overflow: hidden; but also adds flex: 1 1 auto; for use within flex containers.

โœ„๐˜—
tsx code block:
โœ„๐˜—css` ${euiFullHeight()} `
Edit this page

Previous
Resize observer
Next
Text diff
  • Scroll bar style
    • .eui-scrollBar className
    • useEuiScrollBar() hook
  • Vertical (scroll-y)
    • .eui-yScroll className
    • useEuiOverflowScroll('y') hook
  • Horizontal (scroll-x)
    • .eui-xScroll className
    • useEuiOverflowScroll('x') hook
  • Full height layout
    • .eui-fullHeight className
    • euiFullHeight() function
EUI is dual-licensed under Elastic License 2.0 and Server Side Public License, v 1 | Crafted with โค by Elastic