1 estrella en GitHub = 1 componente nuevo.

Dar una estrella
Botonesbuttonshineanimated

Shiny Button

Botón con un destello metálico brillante que recorre la superficie al pasar el cursor.

Vista Previa en Vivo

Uso

Copia y pega este código directamente en tu componente React:

tsx
import { ShinyButton } from 'react-component-kit-ui/buttons';

<ShinyButton variant="primary">Upgrade</ShinyButton>

Instalación Manual

Si no estás usando el paquete npm, crea un archivo nuevo y pega el siguiente código: src/components/ShinyButton.tsx + ShinyButton.css:

ShinyButton.tsx
'use client';

import type { ElementType, HTMLAttributes, ReactNode } from 'react';
import './ShinyButton.css';

/**
 * ShinyButton — A button with a metallic shine effect that sweeps across on hover.
 */
export interface ShinyButtonProps extends HTMLAttributes<HTMLElement> {
  href?: string;
  target?: string;
  rel?: string;
  type?: 'button' | 'submit' | 'reset';
  variant?: 'primary' | 'secondary' | 'ghost';
  size?: 'sm' | 'md' | 'lg';
  disabled?: boolean;
  children?: ReactNode;
}

export function ShinyButton({
  href,
  type = 'button',
  variant = 'primary',
  size = 'md',
  disabled = false,
  className,
  children,
  ...rest
}: ShinyButtonProps) {
  const Tag: ElementType = href ? 'a' : 'button';
  return (
    <Tag
      {...rest}
      href={href}
      type={href ? undefined : type}
      disabled={href ? undefined : disabled}
      aria-disabled={href && disabled ? true : undefined}
      className={['shiny-btn', `shiny-btn--${variant}`, `shiny-btn--${size}`, className].filter(Boolean).join(' ')}
    >
      <span className="shiny-btn__content">{children}</span>
    </Tag>
  );
}

export default ShinyButton;
ShinyButton.css
/* ShinyButton — ported from astro-component-kit (buttons/ShinyButton.astro) */

.shiny-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #111;
  color: #fff;
  padding: 0;
  border: none;
  border-radius: var(--r-md, 12px);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-weight: 600;
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
  font-family: var(--font-sans, inherit);
}

.shiny-btn__content {
  display: block;
  padding: 0.7rem 1.8rem;
  z-index: 2;
}

.shiny-btn::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -150%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    45deg,
    transparent 0%,
    rgba(255, 255, 255, 0) 30%,
    rgba(255, 255, 255, 0.2) 50%,
    rgba(255, 255, 255, 0) 70%,
    transparent 100%
  );
  transform: rotate(45deg);
  transition: left 0.6s ease;
  z-index: 1;
}

.shiny-btn:hover:not(:disabled)::after {
  left: 100%;
}

.shiny-btn:hover:not(:disabled) {
  box-shadow: 0 10px 30px -10px rgba(255, 255, 255, 0.1);
  transform: translateY(-2px);
}

.shiny-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.shiny-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(1);
}

/* Variants */
.shiny-btn--primary {
  background: linear-gradient(135deg, #1e293b, #0f172a);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.shiny-btn--secondary {
  background: var(--c-primary, #6366f1);
}

.shiny-btn--ghost {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--c-text-2, #94a3b8);
}
.shiny-btn--ghost:hover:not(:disabled) {
  color: #fff;
  border-color: #fff;
}

/* Sizes */
.shiny-btn--sm .shiny-btn__content { padding: 0.45rem 1.2rem; font-size: 0.85rem; }
.shiny-btn--md .shiny-btn__content { padding: 0.75rem 1.8rem; font-size: 1rem; }
.shiny-btn--lg .shiny-btn__content { padding: 1.1rem 2.6rem; font-size: 1.15rem; }

Información Rápida

Categoría
Botones
Nombre de archivo
ShinyButton.tsx
Dependencias
Ninguna — React + CSS puro
Etiquetas
buttonshineanimated