ScrollToTop
Button that scrolls to top of page or container
Start Here
Start from the smallest working snippet, then move to interactive examples and the full API contract below.
Styled quick start
Copy this entrypoint first. It includes the imports required to get the component on screen.
<script lang="ts">
import '@dryui/ui/themes/default.css';
import '@dryui/ui/themes/dark.css';
import { ScrollToTop } from '@dryui/ui';
</script>
<ScrollToTop>Content</ScrollToTop>Import options
Root package
import { ScrollToTop } from '@dryui/ui'Per-component subpath
import { ScrollToTop } from '@dryui/ui/scroll-to-top'Customize
Use the interactive examples to see common variants, states, and composition patterns before building your own.
Default (Bottom Right)
ScrollToTop renders a fixed button that appears when the user scrolls past the threshold. Scroll the page down to see it appear in the corner.
<ScrollToTop />Custom Threshold
The button appears after scrolling 200px (default is 100px).
<ScrollToTop threshold={200} />Bottom Left Position
Renders the button in the bottom-left corner instead of bottom-right.
<ScrollToTop position="bottom-left" />Compose
The full API contract lives here: props, CSS variables, and the public data attributes you can target when styling.
| Prop | Type | Default | Required | Bindable |
|---|---|---|---|---|
threshold | number | 300 | — | — |
target | HTMLElement | — | — | — |
behavior | ScrollBehavior | 'smooth' | — | — |
position | bottom-rightbottom-leftbottom-center | 'bottom-right' | — | — |
class | string | — | — | — |
Also accepts standard HTML attributes (class, style, id, etc.)