Scroll To
Button that scrolls to a section or position.
Installation
pnpm dlx shadcn@latest add @paneui/scroll-toUsage
Examples
Accessibility
Set focusTarget to move keyboard focus to a selector or element target after scrolling (it adds tabindex="-1" if needed). Under reduced motion the scroll jumps instead of easing.
Related
Scrolls through Smooth Scroll. See also Scroll Progress, Scroll Reveal.
ScrollTo
Button that eases to a target through the nearest SmoothScroll, or the window. Also accepts every prop of Button.
- to*
- number | string | HTMLElement
- A px offset, a CSS selector or an element.
- offset
- number
- Extra px from the target, e.g.
-64to clear a sticky header. - duration
- number
- Ease duration in seconds, only inside a
SmoothScrollthat is easing. - focusTarget= false
- boolean
- Move keyboard focus to a selector or element target after scrolling.
- onClick
- MouseEventHandler<HTMLButtonElement>
- Runs before scrolling; call
event.preventDefault()to cancel the scroll. - variant= "secondary"
- Button variant
- Visual style.
| Prop | Type | Default | Description |
|---|---|---|---|
| to* | number | string | HTMLElement | — | A px offset, a CSS selector or an element. |
| offset | number | — | Extra px from the target, e.g. -64 to clear a sticky header. |
| duration | number | — | Ease duration in seconds, only inside a SmoothScroll that is easing. |
| focusTarget | boolean | false | Move keyboard focus to a selector or element target after scrolling. |
| onClick | MouseEventHandler<HTMLButtonElement> | — | Runs before scrolling; call event.preventDefault() to cancel the scroll. |
| variant | Button variant | "secondary" | Visual style. |