shadcn.io is not affiliated with official shadcn/ui
Back to Top Footer Block for React
A footer for a long-read magazine that opens with a full-width back-to-top link band, then the brand, three link groups and a legal band.
Installation
Overview
A footer that ends a long scroll for React with Base UI. It opens with a full-width band that is one link, an up arrow, "Back to top" and a hint, "Or press Home", which tints under the pointer and the keyboard. Under it, a band holds the brand (a serif wordmark and a sentence) and three groups of links in a nav labelled Footer, then a legal band closes the footer. The link is a real #top link, so with no script, or with reduced motion, the browser jumps to the top of the page itself; otherwise the script replaces the jump with a smooth scroll. The rails and top rule come from the Guides spine, every band's rule is drawn by Guides, and none is drawn under the legal band because a footer ends the page.
FAQ
How does the scrolling work?
The band is an anchor to #top, which every browser treats as "the top of the document" even when the page has no element with that id. With reduced motion the link's own jump runs. Otherwise a click handler cancels the jump and calls window.scrollTo with behavior: "smooth". If your page scrolls inside a container rather than the window, scroll that element in goTop instead.
Does the Home key do something?
The hint tells the truth about the browser: pressing Home scrolls to the top of a page whenever focus isn't in a text field, so the block adds no key handler of its own. The link also announces Home as its keyboard shortcut for assistive technology.
Where does focus go afterwards?
With a plain jump the browser moves its starting point for the next Tab to the top of the page. With the smooth scroll the block leaves focus on the link, so a keyboard user presses Tab to carry on from the footer; if you prefer, move focus to your page's first heading in goTop once the scroll ends.
What happens with reduced motion?
Nothing animates: the page jumps, the arrow does not lift on hover, and the band's tint appears without a transition.
Related
- Pro
Link Columns Footer
Link gridsThe classic link-column footer for an email API: a brand column with the wordmark, one sentence and four social links, four groups of links behind a split divider, and a legal band with the copyright and the policy links.
- Pro
Stacked Bands Footer
Slim and minimalA footer in three ruled bands: the wordmark, a sentence and the shop's pages; five social links with their names; and the legal row.
- Pro
Social Icons Footer
Slim and minimalA two-row footer: a wordmark and tagline beside five social icon buttons with tooltips, and a ruled band with the copyright and the policy links.
- Pro
Command Palette Footer
Sitemaps and trailsA centred footer for a notes app with a search-or-jump button and Command K shortcut that open a palette listing the footer's own links by group.
- Pro
Language Selector Footer
PreferencesA footer for a meeting-notes tool whose segmented control (EN, FR, DE, ES) rewrites the footer's own words, with three link groups and a legal row.
- Pro
One Row Footer
Slim and minimalThe smallest footer: one row on the spine with a wordmark and a copyright line at the start and four inline links with a drawn underline at the end.