Componentes Botón Seguir Componente del botón Seguir

Componente del botón Seguir

Un componente de botón de seguir/dejar de seguir responsivo adecuado para sitios web de eventos y conferencias, con transiciones degradadas, compatibilidad con modo oscuro y un color de acento brillante. Incluye un sutil efecto de desplazamiento y cambia el texto y el fondo al hacer clic (simulado).

Vista previa

Código HTML

<div class="flex items-center justify-center p-4 bg-gray-100 dark:bg-gray-900 min-h-[150px]">
  <button class="follow-button group relative overflow-hidden px-6 py-2 rounded-full font-semibold text-lg transition-all duration-300 ease-out shadow-md
    bg-gradient-to-r from-red-500 to-purple-600 
    hover:from-purple-600 hover:to-red-500 
    text-white dark:text-gray-100
    focus:outline-none focus:ring-4 focus:ring-purple-300 dark:focus:ring-red-800">
    <span class="relative z-10 block transition-transform duration-300 ease-in-out group-hover:scale-105" data-text-initial="Follow" data-text-followed="Following">Follow</span>
    <span class="absolute inset-0 bg-white opacity-0 transition-opacity duration-300 ease-out group-hover:opacity-10 pointer-events-none"></span>
  </button>

  <script>
    document.addEventListener('DOMContentLoaded', () => {
      const button = document.querySelector('.follow-button');
      const buttonText = button.querySelector('span[data-text-initial]');

      let isFollowing = false;

      button.addEventListener('click', () => {
        isFollowing = !isFollowing;

        if (isFollowing) {
          buttonText.textContent = buttonText.dataset.textFollowed;
          button.classList.remove('from-red-500', 'to-purple-600', 'hover:from-purple-600', 'hover:to-red-500');
          button.classList.add('from-gray-400', 'to-gray-500', 'dark:from-gray-700', 'dark:to-gray-800', 'hover:from-gray-500', 'hover:to-gray-400', 'dark:hover:from-gray-800', 'dark:hover:to-gray-700',
          'text-gray-800', 'dark:text-gray-200');
          button.classList.remove('text-white', 'dark:text-gray-100');
        } else {
          buttonText.textContent = buttonText.dataset.textInitial;
          button.classList.remove('from-gray-400', 'to-gray-500', 'dark:from-gray-700', 'dark:to-gray-800', 'hover:from-gray-500', 'hover:to-gray-400', 'dark:hover:from-gray-800', 'dark:hover:to-gray-700',
          'text-gray-800', 'dark:text-gray-200');
          button.classList.add('from-red-500', 'to-purple-600', 'hover:from-purple-600', 'hover:to-red-500',
          'text-white', 'dark:text-gray-100');
        }
      });
    });
  </script>
</div>

Componentes relacionados

Diseño de materiales Botón de seguimiento

Un componente de botón de seguimiento de Material Design monocromático y receptivo para blogs, con soporte para modo oscuro.

Abrir

Componente del botón Seguir

Un componente de botón "Seguir" complejo y receptivo con degradado y transiciones de color apagadas, diseñado para plataformas inmobiliarias. Incluye soporte para el modo oscuro y utiliza HTML semántico.

Abrir

Componente del botón Seguir

Un componente de botón 'Seguir' receptivo diseñado para plataformas de bienes raíces, con un esquema de color azul corporativo, soporte para modo oscuro y un sutil efecto de desplazamiento interactivo.

Abrir