🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

qwik-scroll-to-top

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

qwik-scroll-to-top

Lightweight button component for scrolling to the top of a page

0.1.2
latest
Source
npm
Version published
Weekly downloads
6
-45.45%
Maintainers
1
Weekly downloads
 
Created
Source

qwik-scroll-to-top

A lightweight and customizable button component that scrolls to the top of a page when pressed
The button is only visible once a certain height has been reached on the page

NPM

Live demo

A live demo can be found here

Installation

With pnpm:

pnpm i qwik-scroll-to-top

With npm:

npm i qwik-scroll-to-top

or with Yarn:

 yarn add qwik-scroll-to-top

Usage

Import and then add <ScrollToTop /> at the bottom of your return function (for a11y reasons):

import { ScrollToTop } from "qwik-scroll-to-top";

function CoolPage() {
  return (
    <div>
      <h1>Hello, world!</h1>
      <div style={{ marginTop: "150vh" }} />
      <ScrollToTop smooth />
    </div>
  );
}

Props

PropTypeDescriptionDefault
useSlotbooleanWhether you want use your passed Slot(children) as Icon of the buttonfalse
smoothbooleanWhether to use smooth scrolling*false
topnumberHeight after page scroll to be visible20
colorstringThe SVG icon fill color"black"
svgPathstringThe SVG icon path d attributeAn arrow path
widthstringThe SVG icon width"28"
heightstringThe SVG icon height"28"
viewBoxstringThe SVG icon viewBox attribute"0 0 256 256"
componentanyComponent to override SVG icon. See examples
styleObjectObject to add/override styling
classstringClass to add/override styling (note, !important for overrides might be needed)

Smooth scrolling uses a newer window.scrollTo implementation.
Check out its support in browsers at MDN web docs.

Examples

With custom SVG path
With custom SVG component
With custom DOM element

Types

Written in TypeScript, no need for @types installation

Ported from: react-scroll-to-top

Keywords

qwik

FAQs

Package last updated on 29 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts