Skip to main content

Horizontal scroll

The horizontal scroller provides an alternative to a horizontal scroll bar. When the screen space is not wide enough to display the whole the of the content, a right arrow (a flipper) is displayed on the right side of the content. The user can click on the arrow to move to the right.

Similarly, as soon as content disappears from view on the left side, a left arrow is displayed at the left of the content so that the user can move back in that direction.

Use cases:

  • where there is insufficient space for horizontal scroll bars
  • where the content is broken into individual horizontal sections

Example

The example below shows the horizontal scroller in action. There are twelve individual cards displayed. If you reduce the size of your window so that they do not all fit, the flipper button appears at the right. If you click to move right, a flipper button appears at the left side to enable you to move back.

Card number 1A buttonCard number 2A buttonCard number 3A buttonCard number 4A buttonCard number 5A buttonCard number 6A buttonCard number 7A buttonCard number 8A buttonCard number 9A buttonCard number 10A buttonCard number 11A buttonCard number 12A button

Declaration

<rapid-horizontal-scroll></rapid-horizontal-scroll>

Usage

@customElement({
name: 'my-element',
template: html`
<rapid-horizontal-scroll>
<rapid-card>
Card number 1
<rapid-button>A button</rapid-button>
</rapid-card>
<rapid-card>
Card number 2
<rapid-button>A button</rapid-button>
</rapid-card>
</rapid-horizontal-scroll>
`,
})
export class MyElement extends GenesisElement {
}
tip

You can use any html content inside the scroll component. You don't have to use <rapid-card>.

API

This table shows attribute binding examples for Genesis Component syntax. The HTML closing tag is not included.

Attributes

NameTypeDescriptionExample
speednumberSpeed of scroll in pixels per second. Default: 600
<rapid-horizontal-scroll speed="750">
durationstringThe CSS time value for the scroll transition duration. Overrides the speed attribute. When duration is set, the speed attribute has no effect.
<rapid-horizontal-scroll duration="300">
easing"linear" | "ease-in" | "ease-out" | "ease-in-out" | stringThe easing value of the scroll. Default "ease-out"
<rapid-horizontal-scroll easing="ease-in">
flippers-hidden-from-atbooleanWhether the flippers are hidden from assistive technology. Default: false
<rapid-horizontal-scroll flippers-hidden-from-at>
view"default" | "mobile"View for this component. Default: default
<rapid-horizontal-scroll view="mobile">

Properties

This component is only controlled via attributes.

Slots

NameDescription
DefaultThis is where you place the content to be scrolled.
startYou can place content before (to the left of) the Default content. This is not scrolled.
endYou can place content after (to the right of) the Default content. This is not scrolled.

Parts

NameDescription
scroll-areaWraps the entire scrollable region.
scroll-viewThe visible scroll area.
content-containerThe container for the content.
scroll-prevThe Previous flipper container.
scroll-action-previousThe element wrapping the Previous flipper.
scroll-nextThe Next flipper container.
scroll-action-nextThe element wrapping the Next flipper.

Events fired

NameDescription
scrollstartFires a custom 'scrollstart' event when scrolling.
scrollendFires a custom 'scrollend' event when scrolling stops.

Events listened to

This component doesn't listen to any events.