맨 위로 이동 버튼
사용자가 페이지를 아래로 스크롤할 때 표시되는 Material Design Back to Top 버튼입니다. 다크 모드 지원과 부드러운 스크롤이 포함됩니다.
HTML 코드
<template>
<button
id="back-to-top-btn"
class="fixed bottom-6 right-6 bg-blue-600 text-white p-3 rounded-full shadow-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-opacity-50 transition duration-300 ease-in-out dark:bg-blue-700 dark:hover:bg-blue-800"
onclick="scrollToTop()"
aria-label="Back to top"
>
<svg
class="w-6 h-6"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M12 6V4m0 2l-3 3m3-3l3 3m-6 6h6a2 2 0 010 4H6a2 2 0 010-4z"
></path>
</svg>
</button>
</template>
<script>
// This script is for demonstration purposes and would typically be in a separate JS file
const backToTopButton = document.getElementById('back-to-top-btn');
window.onscroll = function() {
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
backToTopButton.style.display = "block";
} else {
backToTopButton.style.display = "none";
}
};
function scrollToTop() {
window.scrollTo({ top: 0, behavior: 'smooth' });
}
</script>
<style>
/* Add any necessary component-specific styles here */
#back-to-top-btn {
display: none; /* Hidden by default */
}
</style>
관련 구성 요소
맨 위로 이동 버튼 구성 요소
미니멀하고 평평한 Back to Top Button Component는 대시보드를 위한 것으로, 단색 색 구성표를 특징으로 합니다. 인터랙티브 기능, 반응형 디자인, 어두운 테마 지원으로 적당히 복잡하며 순전히 HTML 및 Tailwind CSS로 구축되었습니다.
브루탈리스트 맨 위로 돌아가기 버튼
Tailwind CSS의 브루탈리즘 백투-맨 위 버튼으로, 높은 대비, 대담한 타이포그래피 및 날카로운 모서리가 있습니다. 반응형 크기 조정 및 다크 모드 지원이 포함됩니다.