This version is in early development and is subject to change and therefore not ready for wide use. There may be other stable versions available.

Smooth scroll utility

This enables smooth scrolling when a user clicks on anchor links or other in-page scrolling is triggered.

github location npm version


This is an opt-in behaviour that is activated by putting the vf-smooth-scroll class on a parent element — a good place would be at <html class="vf-smooth-scroll"> (note: it probably won't work if you add it your <body> element).

Note that as of Safari version 15.4 (released March 2022), CSS-based smooth scrolling is supported by Safari on Mac OS or iOS.


This component targets WCAG 2.1 AA accessibility.

Generally this improves accessibility by smooth scrolling between content, for some scenarios the behaviour may become distracting.

Note that smooth scrolling is disabled if a user has flagged prefers-reduced-motion.

You can also read about the Visual Framework's approach to accessibility.


Scroll to: A B C

Item A

With sub–heading

Item B

With sub–heading

Item C

With sub–heading

<div class="vf-smooth-scroll">

    Scroll to:
    <a href="#pageA">A</a>
    <a href="#pageB">B</a>
    <a href="#pageC">C</a>
  <div class="vf-stack vf-stack--800" style="scroll-behavior: smooth; overflow-y: scroll; height: 100px; max-width: 350px;">
    <article class="vf-card vf-card--brand vf-card--bordered" id="pageA">
      <div class="vf-card__content | vf-stack vf-stack--400">
        <h3 class="vf-card__heading">Item A</h3>
        <p class="vf-card__subheading">With sub–heading</p>
    <article class="vf-card vf-card--brand vf-card--bordered" id="pageB">
      <div class="vf-card__content | vf-stack vf-stack--400">
        <h3 class="vf-card__heading">Item B</h3>
        <p class="vf-card__subheading">With sub–heading</p>
    <article class="vf-card vf-card--brand vf-card--bordered" id="pageC">
      <div class="vf-card__content | vf-stack vf-stack--400">
        <h3 class="vf-card__heading">Item C</h3>
        <p class="vf-card__subheading">With sub–heading</p>


Installation info

This repository is distributed with [npm][]. After [installing npm][] and yarn, you can install vf-smooth-scroll with this command.

$ yarn add --dev @visual-framework/vf-smooth-scroll


The style files included are written in Sass. If you're using a VF-core project, you can import it like this:

@import "@visual-framework/vf-smooth-scroll/vf-smooth-scroll.scss";

Make sure you import Sass requirements along with the modules. You can use a project boilerplate or the vf-sass-starter




  • Updated documentation


  • Introduce CSS-based smooth scroll component.


File system location: components/vf-smooth-scroll

Find an issue on this page? Propose a change or discuss it.