Back-to-Top Button Generator
Create a smooth scroll-to-top button for your website. Customize the icon, colors, size, position, and scroll threshold.
Live Preview
Scroll down on your page to see the button appear
Generated Code
<style>
.btt-btn {
position: fixed;
bottom: 24px;
right: 24px;
width: 48px;
height: 48px;
background: #1a1a2e;
color: #ffffff;
border: none;
border-radius: 24px;
cursor: pointer;
display: none;
align-items: center;
justify-content: center;
z-index: 9999;
transition: opacity 0.3s, transform 0.3s;
box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.btt-btn.visible { display: flex; }
.btt-btn:hover { opacity: 0.85; transform: translateY(-2px); }
</style>
<button class="btt-btn" id="bttBtn" aria-label="Back to top"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M12 19V5M5 12l7-7 7 7"/></svg></button>
<script>
(function() {
var btn = document.getElementById("bttBtn");
window.addEventListener("scroll", function() {
if (window.scrollY > 300) {
btn.classList.add("visible");
} else {
btn.classList.remove("visible");
}
});
btn.addEventListener("click", function() {
window.scrollTo({ top: 0, behavior: "smooth" });
});
})();
</script>