Skip to content

scrollToTop

The scrollToTop function smoothly scrolls the page to the top.

Syntax

typescript
scrollToTop(options?: ScrollToOptions): void;

Parameters

NameTypeDescription
optionsScrollToOptions(optional) Scrolling options

Returns

NameTypeDescription
voidDoes not return a value

Examples

typescript
scrollToTop();
// Scrolls to the top of the page

scrollToTop({ behavior: "smooth" });
// Smoothly scrolls to the top

Notes

  • Useful for quick navigation on long pages.

References

Released under the MIT License.