Skip to main content

Scroll Principle

The scroll prop can be used to set up when a scroll bar should show. We provide the following scrolling options on our container components:

export interface ScrollProp {
scroll?:
| 'overflow' /** default */
| 'both'
| 'vertical'
| 'horizontal'
| 'hidden';
}

overflow

By default content will overflow its container. In the example below we force the container to be small (with explicit sizing 90px) and then throw a bunch of content inside it (note the lightpink sections are overflowing lightskyblue)

Live Editor
Result
Loading...
info

There is no need to be alarmed by this default value. You normally don't use explicit size (covered in the scale principle). Content will overflow to the body, and the browser will add a scrollbar on the body for you (by default).

both | vertical | horizontal

Add scroll: 'both'| 'vertical' | 'horizontal' to finely control where you want your scroll bar to appear.

Some configuration handled for you:

  • The scrollbar will only show if the content actually overflows.
  • The scrolling section is touch-smooth-scroll enabled.

Here is an example where content doesn't overflow (and you don't see a scroll bar despite scroll='both'):

Live Editor
Result
Loading...

Here is an example where content does overflow:

Live Editor
Result
Loading...

You can use it to fine tune the scroll bar location e.g. below we want the header to stay outside the scroll bar:

Live Editor
Result
Loading...

hidden

It behaves exactly like you would expect, cutting off overflowing content and not letting you scroll to it:

Live Editor
Result
Loading...

Example use case - Clipping an image at the border, a common pattern in landing pages:

Live Editor
Result
Loading...