Skip to content

Create a "Back to Top" Block #50433

Closed as not planned
Closed as not planned

Description

@beafialho

What problem does this address?

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:

Captura de ecrã 2023-05-08, às 14 52 26

Captura de ecrã 2023-05-08, às 14 55 55

Captura de ecrã 2023-05-08, às 15 06 30

cc: @iamarinoh @iamtakashi @jasmussen

Activity

  1. added
    Needs Design Feedback
    [Feature] Design Tools
    on May 8, 2023
  2. jasmussen commented on May 8, 2023

    @jasmussen
    Contributor

    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.

  3. added
    Needs Technical Feedback
    on May 8, 2023
  4. added
    New Block
    on May 9, 2023
  5. iamtakashi commented on May 9, 2023

    @iamtakashi

    +1. Thanks for opening the issue, @beafialho!

  6. gziolo commented on May 9, 2023

    @gziolo
    Member

    I wanted to share another use case for the "Top" link:

    image

    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.

  7. ramonjd commented on May 10, 2023

    @ramonjd
    Member

    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 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).

  8. carolinan commented on May 10, 2023

    @carolinan
    Contributor

    Another reason to allow users to upload svgs so that the icon can be customized...

  9. jasmussen commented on May 10, 2023

    @jasmussen
    Contributor

    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.

  10. added
    Needs Dev
    and removed
    Needs Design Feedback
    on May 10, 2023
  11. self-assigned this
    on May 10, 2023
  12. hanneslsm commented on May 12, 2023

    @hanneslsm
  13. added
    [Status] In Progress
    on May 12, 2023
  14. added
    [Type] Enhancement
    on Jul 19, 2023
  15. richtabor commented on Apr 30, 2024

    @richtabor
    Member

    I think this could be an interesting idea as a standalone block per #58773.

  16. removed their assignment
    on Nov 1, 2024
  17. TheJeffr0 commented on Jan 31, 2025

    @TheJeffr0

    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.

  18. Mamaduka commented on Apr 23, 2025

    @Mamaduka
    Member

    Closing this as "maybe later".

    Why?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs DevNeeds Technical FeedbackNew Block[Feature] Design Tools[Status] In Progress[Type] Enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions