PRACTICAL WEB TIP
SOFT PILL — Back to Top
SOFT PILL: a reusable Back to Top control with gentle idle motion and carefully paced hover feedback.
Design Preview
See the design above before trying the scroll interaction.
Live Demo
Press Try scrolling inside the frame, or scroll inside it. The button appears at the lower right and returns you to the top.
Source Code
Copy the HTML, CSS or JavaScript you need for your project.
<div class="tbtt-widget" data-tb-btt-id="2137"><button aria-label="Return to top" class="tb-btt t2137" title="Back to top" type="button"><span class="disc"><i>↑</i></span><span class="copy"><b>BACK TO TOP</b><small>RETURN TO START</small></span></button></div>
/* TIPSBLOCKS TB-2137 — installable self-contained UI. */
.tbtt-widget{position:fixed;z-index:9999;right:clamp(12px,2vw,30px);bottom:clamp(16px,2.5vw,36px);visibility:hidden;opacity:0;pointer-events:none;transform:translateY(12px);transition:opacity .36s ease,transform .45s ease,visibility .36s ease}
.tbtt-widget.is-shown{opacity:1;visibility:visible;pointer-events:auto;transform:translateY(0)}
.tbtt-widget--edge{right:0}
.tbtt-widget--footer{position:absolute;right:0;bottom:0;visibility:visible;opacity:1;pointer-events:auto;transform:none}
.tbtt-widget .tb-btt{--ease:cubic-bezier(.22,.67,.18,1);--hover:.85s;font-family:Inter,"Helvetica Neue",Arial,"Noto Sans CJK JP",sans-serif}
.tbtt-widget .tb-btt:focus-visible{outline:3px solid #1593b1;outline-offset:5px}
.tbtt-widget .tb-btt span,.tbtt-widget .tb-btt i,.tbtt-widget .tb-btt b,.tbtt-widget .tb-btt em,.tbtt-widget .tb-btt small,.tbtt-widget .tb-btt strong{pointer-events:none}
@media(max-width:670px){.tbtt-widget:not(.tbtt-widget--footer){right:12px;bottom:18px}.tbtt-widget--edge{right:0!important}.tbtt-widget--footer{right:0}}
@media(prefers-reduced-motion:reduce){.tbtt-widget,.tbtt-widget *,.tbtt-widget *::before,.tbtt-widget *::after{animation:none!important;transition-duration:.01ms!important}}
.tb-btt{appearance:none;border:0;padding:0;line-height:1;isolation:isolate;position:relative;display:inline-flex;align-items:center;justify-content:center;flex:none;cursor:pointer;-webkit-tap-highlight-color:transparent;white-space:nowrap;font-synthesis:none;text-rendering:optimizeLegibility;color:#263830;transition:color var(--hover) var(--ease),background var(--hover) var(--ease),border-color var(--hover) var(--ease),box-shadow var(--hover) var(--ease),transform var(--hover) var(--ease);outline-offset:5px}
.tb-btt:focus-visible{outline:3px solid #1593b1;outline-offset:5px}
.tb-btt span,.tb-btt i,.tb-btt b,.tb-btt em,.tb-btt small,.tb-btt strong{pointer-events:none;box-sizing:border-box}
.tb-btt span,.tb-btt i,.tb-btt b,.tb-btt em,.tb-btt small,.tb-btt strong,.tb-btt::before,.tb-btt::after{transition-duration:var(--hover);transition-timing-function:var(--ease)}
.t2137{width:184px;height:58px;background:#fbf6ec;border:1px solid #d6c6b0;border-radius:32px;box-shadow:0 7px 18px #463c2617;justify-content:flex-start;padding:5px;gap:11px;color:#333e36}.t2137 .disc{width:45px;height:45px;border-radius:50%;background:#31473f;color:white;display:grid;place-items:center;flex:none}.t2137 .disc i{font:300 25px/1 Arial;animation:a2137 7s ease-in-out infinite}.t2137 .copy{display:flex;flex-direction:column;gap:6px;align-items:flex-start}.t2137 b{font:700 11.2px/1 Arial;letter-spacing:1.25px}.t2137 small{font:600 9px/1 Arial;letter-spacing:1.1px;color:#9b8270}.t2137:hover{border-color:#789787;box-shadow:0 11px 23px #463c2625}.t2137:hover .disc{background:#bf7961}.t2137:hover .copy{transform:translateX(3px)}@keyframes a2137{0%,12%,100%{transform:translateY(0)}30%{transform:translateY(-5px)}48%{transform:translateY(0)}}
.t2137 .disc i{animation:a2137v5 7.2s cubic-bezier(.25,.67,.25,1) infinite}
@keyframes a2137v5{0%,12%,100%{transform:translateY(0);opacity:.72}34%,57%{transform:translateY(-6px);opacity:1}77%{transform:translateY(0);opacity:.72}}
(()=>{'use strict';const host=document.querySelector('.tbtt-widget[data-tb-btt-id="2137"]');if(!host)return;const btn=host.querySelector('.tb-btt');const reduce=window.matchMedia('(prefers-reduced-motion: reduce)');function update(){const y=Math.max(0,window.scrollY||document.documentElement.scrollTop||0);if(!host.classList.contains('tbtt-widget--footer'))host.classList.toggle('is-shown',y>200);const all=Math.max(1,document.documentElement.scrollHeight-window.innerHeight);const pct=Math.round(Math.min(100,100*y/all));btn.style.setProperty('--progress',pct+'%');const pctNode=btn.querySelector('.pct');if(pctNode)pctNode.textContent=pct+'%';}btn.addEventListener('click',()=>window.scrollTo({top:0,behavior:reduce.matches?'auto':'smooth'}));window.addEventListener('scroll',update,{passive:true});window.addEventListener('resize',update,{passive:true});update();})();
How to Use
Insert the HTML button near the end of body, load the CSS, and include JavaScript using defer. Test scrolling, returning to the top, and positioning on mobile.
Use Case
General-purpose navigation for editorial sites, business websites, and content-heavy pages.
Technical Notes
Keep controls usable on touch devices. Test keyboard focus and reduced-motion preferences.
Mobile:Check tap target, visibility and positioning on small screens.
Browser:Designed for current Chrome, Edge, Firefox and Safari.
Reduced Motion:CSS animations respect the reduced-motion preference.