---
id: api/commands/scrollintoview
title: scrollIntoView | Cypress Documentation
description: Scroll an element into view in Cypress.
section: api
source_path: docs/api/commands/scrollintoview.mdx
version: 7ada28c0cd90e81cf56fd3fc73de6e6d45c16de6
updated_at: '2026-05-13T21:55:41.935Z'
---
# scrollIntoView

Scroll an element into view.

It is [unsafe](/llm/markdown/app/core-concepts/retry-ability.md#Only-queries-are-retried) to chain further commands that rely on the subject after `.scrollIntoView()`.

## Syntax

```
.scrollIntoView().scrollIntoView(options)
```

### Usage

**Correct Usage**

```
cy.get('footer').scrollIntoView() // Scrolls 'footer' into view
```

**Incorrect Usage**

```
cy.scrollIntoView('footer') // Errors, cannot be chained off 'cy'cy.window().scrollIntoView() // Errors, 'window' does not yield DOM element
```

### Arguments

**options _(Object)_**

Pass in an options object to change the default behavior of `.scrollIntoView()`.

| Option | Default | Description |
| --- | --- | --- |
| `duration` | `0` | Scrolls over the duration (in ms) |
| `easing` | `swing` | Will scroll with the easing animation |
| `log` | `true` | Displays the command in the [Command log](/llm/markdown/app/core-concepts/open-mode.md#Command-Log) |
| `offset` | `{top: 0, left: 0}` | Amount to scroll after the element has been scrolled into view |
| `timeout` | [`defaultCommandTimeout`](/llm/markdown/app/references/configuration.md#Timeouts) | Time to wait for `.scrollIntoView()` to resolve before [timing out](#Timeouts) |

### Yields [Learn about subject management](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Subject-Management)

*   `.scrollIntoView()` yields the same subject it was given.
*   It is [unsafe](/llm/markdown/app/core-concepts/retry-ability.md#Only-queries-are-retried) to chain further commands that rely on the subject after `.scrollIntoView()`.

## Examples

### Scrolling

```
cy.get('button#checkout').scrollIntoView().should('be.visible')
```

### Options

#### Use linear easing animation to scroll

```
cy.get('.next-page').scrollIntoView({ easing: 'linear' })
```

#### Scroll to element over 2000ms

```
cy.get('footer').scrollIntoView({ duration: 2000 })
```

#### Scroll 150px below an element

```
cy.get('#nav').scrollIntoView({ offset: { top: 150, left: 0 } })
```

## Notes

### Snapshots

#### Snapshots do not reflect scroll behavior

_Cypress does not reflect the accurate scroll positions of any elements within snapshots._ If you want to see the actual scrolling behavior in action, we recommend using [`.pause()`](/llm/markdown/api/commands/pause.md) to walk through each command or [watching the video of the test run](/llm/markdown/app/guides/screenshots-and-videos.md#Videos).

## Rules

### Requirements [Learn about chaining commands](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Chains-of-Commands)

*   `.scrollIntoView()` requires being chained off a command that yields DOM element(s).

### Assertions [Learn about assertions](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Assertions)

*   `.scrollIntoView()` will automatically wait for assertions you have chained to pass

### Timeouts [Learn about timeouts](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Timeouts)

*   `.scrollIntoView()` can time out waiting for assertions you've added to pass.

## Command Log

**_Assert element is visible after scrolling it into view_**

```
cy.get('#scroll-horizontal button').scrollIntoView().should('be.visible')
```

The commands above will display in the Command Log as:

When clicking on the `scrollintoview` command within the command log, the console outputs the following:

## See also

*   [`cy.scrollTo()`](/llm/markdown/api/commands/scrollto.md)
