Scroll To

Button that scrolls to a section or position.

Installation

pnpm dlx shadcn@latest add @paneui/scroll-to

Usage

Examples

Variants and Sizes

Duration

Outside a Provider

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.

Scrolls through Smooth Scroll. See also Scroll Progress, Scroll Reveal.

API Reference

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. -64 to clear a sticky header.
duration
number
Ease duration in seconds, only inside a SmoothScroll that 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.
PropTypeDefaultDescription
to*number | string | HTMLElement—A px offset, a CSS selector or an element.
offsetnumber—Extra px from the target, e.g. -64 to clear a sticky header.
durationnumber—Ease duration in seconds, only inside a SmoothScroll that is easing.
focusTargetbooleanfalseMove keyboard focus to a selector or element target after scrolling.
onClickMouseEventHandler<HTMLButtonElement>—Runs before scrolling; call event.preventDefault() to cancel the scroll.
variantButton variant"secondary"Visual style.