Skip to content

BackTop

A back-to-top button fixed to a corner of the viewport; clicking it smooth-scrolls back to the top of the page.

Basic usage

The button is fixed to the bottom-right corner of the viewport by default (bottom: 32px; right: 32px); scroll the page then click to go back to the top.

Basic usage

Custom position

Custom position

Show / hide control

Show / hide control

Show / Hide

Click event

Click event

Show button

API

Attributes

AttributeDescriptionTypeDefault
bottomDistance from the viewport bottomstring32px
rightDistance from the viewport right edgestring32px
visibleWhether the button is shownboolean

Events

EventDescription
oas-clickThe button was clicked (then smooth-scrolls to the top)

The button is position: fixed on the viewport; the :host defaults to display: inline-block; the button has aria-hidden="true" when hidden.