Put BackToTop once on a long page with a BackToTopButton in it. Pass a skip link as focusTarget, so focus lands there after the scroll.
docs-page.tsx
BackToTop
<div>| Prop | Type | Default | Description |
|---|---|---|---|
| container | RefObject<HTMLElement | null> | — | The element that scrolls, for a panel or a Scroll Area viewport. Without it the page counts, and the button floats at the end-bottom corner of the window. With it, place BackToTop as the last child inside that element: it sticks to its end-bottom corner. |
| threshold | number | 400 | The scroll in px before it shows. Default 400. |
| show | "scroll""scroll-up" | "scroll" | scroll: it shows past the threshold (default). scroll-up: only while the reader scrolls back up. |
| offset | number | 0 | Lifts it by this many px, above a bottom bar, a cookie bar, or a chat launcher. Default 0. |
| focus | RefObject<HTMLElement | null> | — | Where focus lands after the scroll: a skip link or the page heading. Default: the container, or the body. |
| disabled | boolean | false | Hides it and stops the work. |
| ...props | <div> attributes | — | Every other attribute goes to the <div>, with a ref. |
BackToTopButton
<button>| Prop | Type | Default | Description | ||||
|---|---|---|---|---|---|---|---|
| class | string | — | |||||
| busy | boolean | — | The button waits for the app (busy words): a spinner, aria-busy, and no clicks. Focus stays on the button. The style hook stays data-loading. | ||||
| spinner | "center""start" | — | center (default): the spinner covers the label. start: it takes the leading icon slot. The icon sizes always use center, because their one icon is the label. | ||||
| glass | "clear""dark""light" | — | |||||
| size | "default""lg""sm" | "default" | sm 36px (with a 44px touch target), default 44px, or lg 52px. | ||||
| shortcut | string | null | "Home" | The key the tooltip names. Default "Home"; null shows no key. | ||||
From Base UIButtonBase UI docs | |||||||
| focusable | boolean | false | Whether the button should be focusable when disabled. | ||||
| render | — | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render. | |||||
| style | — | Style applied to the element, or a function that returns a style object based on the component's state. | |||||
| |||||||
| ...props | <button> attributes | — | Every other attribute goes to the <button>, with a ref. | ||||
BackToTopPill
<button>| Prop | Type | Default | Description | ||||
|---|---|---|---|---|---|---|---|
| class | string | — | |||||
| busy | boolean | — | The button waits for the app (busy words): a spinner, aria-busy, and no clicks. Focus stays on the button. The style hook stays data-loading. | ||||
| spinner | "center""start" | — | center (default): the spinner covers the label. start: it takes the leading icon slot. The icon sizes always use center, because their one icon is the label. | ||||
| glass | "clear""dark""light" | — | |||||
| size | "default""icon""icon-lg""icon-sm""icon-xs""lg""sm""xl""xs" | "default" | |||||
From Base UIButtonBase UI docs | |||||||
| focusable | boolean | false | Whether the button should be focusable when disabled. | ||||
| render | — | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render. | |||||
| style | — | Style applied to the element, or a function that returns a style object based on the component's state. | |||||
| |||||||
| ...props | <button> attributes | — | Every other attribute goes to the <button>, with a ref. | ||||
| EnterorSpace | On the button: scrolls back to the top, then moves focus to focusTarget. |
|---|
Built with
Installs with Back To Top











