Go Main page
Go Main page

Web components

cover

utilities types

useScrollPosition

v.1.0.0 | Saturn
Healthy
Github

Hook used to get the current scroll position of the window.

Params

useScrollPosition does not take any parameters.

Response

useScrollPosition returns the current scroll position.

Usage example

12345678910
import { useScrollPosition } from '@kubit-ui-web/react-components';

const MyComponent = () => {
  const scroll = useScrollPosition();
  const scrolling = scroll > 0;

  return (
    <div>
      <header scrolling={scrolling}>This is an example</header>
    </div>