Smooth Scroll's Javascript is globally initialized with our
KTAppwrapper defined in
src/js/layout/app.js.
To include Smooth Scroll into your project, you need to include a HTML attribute
data-kt-scroll-togglewithin the
aelement with a
hrefset with a hastag
#. For more options available, such as
offsetparameters, please refer to the initialization definition in
src/js/layout/app.js.
For more information on Smooth Scroll's other options, please refer to the official
plugin site.
Basic Example
Click on the button below to scroll to the top without any offset.
<ahref="#top"class="btn btn-primary"data-kt-scroll-toggle>Scroll to Top</a><divid="top">
...
</div>
Offset Example
Click on the button below to scroll to "Usage" with offset. Add the HTML attribute
data-kt-scroll-offsetwith the offset value in
pxto the anchor element.
<ahref="#usage"class="btn btn-primary"data-kt-scroll-toggle>Scroll to Usage</a><divid="usage"data-kt-scroll-offset="85">
...
</div>
Responsive Offset Example
Click on the button below to scroll to "Initialization" with a responsive offset. Add the HTML attribute
data-kt-scroll-offsetwith the offset value in
pxto the anchor element. The responsive values follows the standard Bootstrap breakpoints where
defaultrepresents the base size and moves up with
sm,
md,
lgor
xl.