File size: 1,965 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
---
meta:
  title: useScroll | React Spring
  'og:title': useScroll | React Spring
  'twitter:title': useScroll | React Spring
  description: API documentation for the useScroll utility hook in React Spring.
  'og:description': API documentation for the useScroll utility hook in React Spring.
  'twitter:description': API documentation for the useScroll utility hook in React Spring.
  'og:url': https://www.react-spring.dev/docs/utilities/use-scroll
  'twitter:url': https://www.react-spring.dev/docs/utilities/use-scroll
sidebar_position: 3
isNew: true
---

import { formatFrontmatterToRemixMeta } from '../helpers/meta'

export const meta = formatFrontmatterToRemixMeta(frontmatter)

# useScroll

A small utility abstraction around our signature [`useSpring`](/docs/components/use-spring) hook. It's a great way to
create a scroll-linked animation. With either the raw value of distance or a 0-1 progress value. You can either use the
scroll values of the whole document, or just a specific element.

## Usage

The example below will start off with an `opacity` of `0` but when the user scrolls to the bottom of the page it will have
reached an `opacity` of `1`.

```tsx
import { useScroll, animated } from '@react-spring/web'

function MyComponent() {
  const { scrollYProgress } = useScroll()

  return (
    <animated.div style={{ opacity: scrollYProgress }}>
      Hello World
    </animated.div>
  )
}
```

## Reference

import { TablesConfiguration } from '../components/Tables/TablesConfig'
import { USE_SCROLL_CONFIG_DATA } from '../data/fixtures'

<TablesConfiguration data={USE_SCROLL_CONFIG_DATA} />

## Typescript

```tsx
function useScroll(configuration: ConfigObject): SpringValues
```

Where `ConfigObject` is described [above](#reference)

## Examples

import { ExampleGrid } from '../components/Grids/ExampleGrid'

<ExampleGrid sandboxTitles={['Scrolling Wave']} />

Can't find what you're looking for? Check out all our [examples!](/examples)