Đó là một thành phần nút đẹp mắt thu hút ánh nhìn bằng một dải ánh sáng (hiệu ứng lung linh) di chuyển khi di chuột và định kỳ. Lý tưởng cho CTA (Kêu gọi hành động) nơi bạn muốn thu hút sự chú ý của người dùng.

Xem trước

Trường hợp sử dụng & Tính năng

Những điểm chính của thiết kế và UX (Design & UX)

Cách tùy chỉnh (Hướng dẫn tùy chỉnh)

Mã triển khai (Implementation)

HTML & CSS (Tailwind CSS併用)

<button class="shimmer-btn text-slate-200 bg-slate-900 border border-slate-700/50 px-8 py-3 rounded-full font-medium transition-all duration-300 hover:-translate-y-1 hover:shadow-lg hover:shadow-slate-500/20 focus:outline-none focus:ring-2 focus:ring-slate-400 focus:ring-offset-2 focus:ring-offset-slate-950">

<span class="relative z-10 flex items-center gap-2">

  <svg class="w-5 h-5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">

    <path stroke-linecap="round" stroke-linejoin="round" d="M13 10V3L4 14h7v7l9-11h-7z" />

  </svg>

  Get Started

</span>

</button>



<style>
.shimmer-btn {

  position: relative;

  overflow: hidden;

}



.shimmer-btn::before {

  content: '';

  position: absolute;

  top: 0;

  left: -100%;

  width: 50%;

  height: 100%;

  background: linear-gradient(

    90deg,

    transparent,

    rgba(255, 255, 255, 0.2),

    transparent

  );

  transform: skewX(-20deg);

  animation: shimmer 3s infinite;

}



@keyframes shimmer {

  0% { left: -100%; }

  20% { left: 200%; }

  100% { left: 200%; }

}
</style>

Phản ứng (Cấu hình Tailwind)

Đây là một phương pháp có thể được hoàn thành trong thành phần React bằng cách mở rộng tệp cấu hình Tailwind (tailwind.config.js).