Skip to main content
Version: v8.1.0-alpha.2

ontario-back-to-top

Use a Back to Top button to help users quickly navigate to the top of a long page.

Usage guidance

Please refer to the Ontario Design System for current documentation guidance.

Configuration

Once the component package has been installed (see Ontario Design System Component Library for installation instructions), the Back to Top component can be added directly into the project's code, and can be customized by updating the properties outlined here. Please see the examples below for how to configure the component.

Examples

By default, the Back to Top button will have its language set to English ('en'). However, a property can be passed to set the language to French by default. For example:

<ontario-back-to-top language="fr"> </ontario-back-to-top>

Otherwise, a default Back to Top button can be used as follows:

<ontario-back-to-top> </ontario-back-to-top>

Technical Note: SSR (Server-Side Rendering) Considerations

The Ontario Back to Top component supports server-side rendering, with a few considerations:

  • Scroll behaviour and visibility toggling: These rely on window and scroll position, which are only available in the browser. These features activate after hydration.
  • Language prop: Pass language explicitly during SSR.
  • Hydrated-only language events: Language change events only fire after hydration.

Overview

Ontario Back to Top helps users quickly return to the top of long pages.

For component guidance, see:

Properties

PropertyAttributeDescriptionTypeDefault
languagelanguageThe language of the component. This is used for translations, and is by default set through event listeners checking for a language property from the header. If no language prop is passed, it will default to English."en" | "fr" | undefinedundefined

Built with StencilJS