---
title: "Scroll To Button"
description: "Free React scroll to button: smooth scrolls to an offset, selector or element through the smooth scroll provider, and jumps under reduced motion. shadcn install."
category: "Components"
parent: "https://beui.dev/components/motion/scroll-animation"
publishedAt: "2026-06-24"
updatedAt: "2026-11-10"
documentation: "https://beui.dev/components/motion/scroll-animation/scroll-to"
markdown: "https://beui.dev/components/motion/scroll-animation/scroll-to.md"
license: "MIT"
---

# Scroll To Button

> Free React scroll to button: smooth scrolls to an offset, selector or element through the smooth scroll provider, and jumps under reduced motion. shadcn install.

## Install

```bash
npx shadcn@latest add @beui/scroll-to
```

## Dependencies

- `clsx`
- `lenis`
- `motion`
- `react`
- `tailwind-merge`

## Usage

### Scroll To usage

Button that smooth-scrolls to a target (offset, selector or element) via the active SmoothScroll provider; reduced-motion jumps instantly.

```tsx
"use client";

import { ScrollTo } from "@/components/motion/scroll-to";
import { SmoothScroll } from "@/components/motion/smooth-scroll";

// ScrollTo uses the active SmoothScroll provider. Here it's contained
// (root={false}); the nav buttons glide the box to each section.
const SECTIONS = [
  { id: "sec-intro", label: "Intro" },
  { id: "sec-features", label: "Features" },
  { id: "sec-pricing", label: "Pricing" },
  { id: "sec-faq", label: "FAQ" },
];

export function ScrollToPreview() {
  return (
    <SmoothScroll
      root={false}
      className="relative h-80 w-full max-w-lg overflow-y-auto scrollbar-hide rounded-2xl border border-border bg-card"
    >
      <nav className="sticky top-0 z-10 flex gap-1.5 border-b border-border bg-background/80 p-2 backdrop-blur">
        {SECTIONS.map((s) => (
          <ScrollTo
            key={s.id}
            to={`#${s.id}`}
            offset={-48}
            className="rounded-full px-3 py-1 text-sm text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"
          >
            {s.label}
          </ScrollTo>
        ))}
      </nav>

      {SECTIONS.map((s) => (
        <section
          id={s.id}
          key={s.id}
          className="flex h-64 items-center justify-center text-lg font-medium text-foreground"
        >
          {s.label}
        </section>
      ))}
    </SmoothScroll>
  );
}
```

## API Reference

### ScrollTo

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `to` | `ScrollTarget` | — | Yes | Where to scroll: px offset, selector string or element. |
| `offset` | `number` | — | No | Extra px offset from the target (e.g. to clear a sticky header). |
| `duration` | `number` | — | No | Override the ease duration in seconds. |
| `className` | `string` | — | No | Classes merged onto the button. |

## More in Scroll Animation

- [Smooth Scroll](https://beui.dev/components/motion/scroll-animation/smooth-scroll.md)
- [Scroll Progress](https://beui.dev/components/motion/scroll-animation/scroll-progress.md)
- [Parallax Scroll](https://beui.dev/components/motion/scroll-animation/parallax.md)
- [Scroll Reveal](https://beui.dev/components/motion/scroll-animation/scroll-reveal.md)

## Source

- Registry detail: https://beui.dev/r/scroll-to
- Raw source: https://beui.dev/r/scroll-to/raw
- GitHub: https://github.com/starc007/ui-components
