C’est un magnifique composant de bouton qui attire le regard avec une bande de lumière (effet chatoyant) qui coule au survol et périodiquement. Idéal pour les CTA (Call To Action) où vous souhaitez attirer l’attention de l’utilisateur.

Aperçu

Cas d’utilisation et fonctionnalités

Points clés du design et de l’UX (Design & UX)

Comment personnaliser (Guide de personnalisation)

Code d’implémentation (Implémentation)

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>

Réagir (configuration Tailwind)

Il s’agit d’une approche qui peut être complétée au sein d’un composant React en étendant le fichier de configuration Tailwind (tailwind.config.js).