You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The popularity of responsive web design has led to a proliferation of single-column, long-page designs both on mobile and desktop. A consequence of these designs has been the Back to Top button, which is a shortcut that allows users to quickly navigate to the top of the page.
What is your proposed solution?
I suggest adding this feature to the site editor, perhaps it makes sense for it to be a block, instead of a hidden feature in the Button block.
I expect it to be fully customisable (colors, typography, background, sticky vs non-sticky, etc) here are a few example designs:
I like it, I think it's useful and valid, and as combined with sticky positioning as a separate tool, it seems very feasible to do.
Technically it seems a matter of adding <a href="#top">Back to top</a> in a block, with whatever customization options we might want. Digging a little bit, it seems like that should work out of the box in modern browsers, as supposedly they are able to parse the #top location without the need for a named anchor or an ID. But please if I'm incorrect in this, please correct me, as this is an important aspect to be sure of, before starting. If this is not a safe assumption, it's technically a more challenging issue.
While you could recreate it with the Group block that displays Heading and Top blocks displayed in sma row, it might be pretty inconvenient to repeat it with all headings on the page. Usually, this type of UI elements you see injected with a plugin that either filters HTML or injects HTML with JavaScript.
Aside, there is a discussion about a new concept in #50029 - Block Behaviors. The scope is still not fully defined, but the idea is that not everything on the page needs to be a block.
Digging a little bit, it seems like that should work out of the box in modern browsers, as supposedly they are able to parse the #top location without the need for a named anchor or an ID. But please if I'm incorrect in this, please correct me, as this is an important aspect to be sure of, before starting. If this is not a safe assumption, it's technically a more challenging issue.
I'm going to assume that the designs provided are sufficient for a dev to pick this one up. I'm thinking a first version can just be an editable rich text field that defaults to outputting "Back to top", with no inspector options and just regular rich text toolbar options. Any iconography can then be inserted as unicode glyphs (such as ↑) or emoji in the rich text, and hopefully through an "Icon" inline-block or other feature in the future.
But if these do need more design, let me know and we'll put something together.
This feature typically requires only a couple of lines of code to implement in projects.
User preferences for this block are "limitless", and providing complete flexibility in core is a complex task compared to the benefits. See the 80% principle in https://wordpress.org/about/philosophy/.
Activity
jasmussen commentedon May 8, 2023
I like it, I think it's useful and valid, and as combined with sticky positioning as a separate tool, it seems very feasible to do.
Technically it seems a matter of adding
<a href="#top">Back to top</a>in a block, with whatever customization options we might want. Digging a little bit, it seems like that should work out of the box in modern browsers, as supposedly they are able to parse the#toplocation without the need for a named anchor or an ID. But please if I'm incorrect in this, please correct me, as this is an important aspect to be sure of, before starting. If this is not a safe assumption, it's technically a more challenging issue.iamtakashi commentedon May 9, 2023
+1. Thanks for opening the issue, @beafialho!
gziolo commentedon May 9, 2023
I wanted to share another use case for the "Top" link:
Example page from the WordPress developer portal:
https://developer.wordpress.org/reference/functions/clean_user_cache/
While you could recreate it with the Group block that displays Heading and Top blocks displayed in sma row, it might be pretty inconvenient to repeat it with all headings on the page. Usually, this type of UI elements you see injected with a plugin that either filters HTML or injects HTML with JavaScript.
Aside, there is a discussion about a new concept in #50029 - Block Behaviors. The scope is still not fully defined, but the idea is that not everything on the page needs to be a block.
ramonjd commentedon May 10, 2023
I like this idea.
Seems like the assumption is pretty accurate!
https://caniuse.com/?search=%23top
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#sect6
If we wanted to get tricky we could have a smooth scroll option as well (might require a bit of JS).
carolinan commentedon May 10, 2023
Another reason to allow users to upload svgs so that the icon can be customized...
jasmussen commentedon May 10, 2023
Awesome, thanks for all the feedback!
I'm going to assume that the designs provided are sufficient for a dev to pick this one up. I'm thinking a first version can just be an editable rich text field that defaults to outputting "Back to top", with no inspector options and just regular rich text toolbar options. Any iconography can then be inserted as unicode glyphs (such as ↑) or emoji in the rich text, and hopefully through an "Icon" inline-block or other feature in the future.
But if these do need more design, let me know and we'll put something together.
hanneslsm commentedon May 12, 2023
richtabor commentedon Apr 30, 2024
I think this could be an interesting idea as a standalone block per #58773.
TheJeffr0 commentedon Jan 31, 2025
We're using a Paragraph block with text that says Return to Top and it links to # until something like it is added to core, which I'm in favor of.
Mamaduka commentedon Apr 23, 2025
Closing this as "maybe later".
Why?