Buttons buttonshineanimated

Shiny Button

A button with a metallic shine effect that sweeps across on hover.

Preview

Usage

Copy the full block below to use this component with its imports.

astro
---
import { ShinyButton } from 'astro-component-kit';
---

<ShinyButton 
  href="#" 
  variant="primary" 
  size="lg"
>
  Claim Special Offer
</ShinyButton>
--- import { ShinyButton } from 'astro-component-kit'; --- <ShinyButton href="#" variant="primary" size="lg" > Claim Special Offer </ShinyButton>

Manual Installation

If you are not using the npm package, create a new file src/components/lib/ShinyButton.astro and paste the following code:

astro
---
interface Props {
  href?: string;
  type?: 'button' | 'submit' | 'reset';
  variant?: 'primary' | 'secondary' | 'ghost';
  size?: 'sm' | 'md' | 'lg';
  disabled?: boolean;
}

const { 
  href, 
  type = 'button', 
  variant = 'primary', 
  size = 'md',
  disabled = false 
} = Astro.props;

const Tag = href ? 'a' : 'button';
---

<Tag 
  href={href} 
  type={href ? undefined : type}
  disabled={disabled}
  class={`shiny-btn shiny-btn--${variant} shiny-btn--${size}`}
>
  <span class="shiny-btn__content"><slot /></span>
</Tag>

<style>
  .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; }
</style>
--- interface Props { href?: string; type?: 'button' | 'submit' | 'reset'; variant?: 'primary' | 'secondary' | 'ghost'; size?: 'sm' | 'md' | 'lg'; disabled?: boolean; } const { href, type = 'button', variant = 'primary', size = 'md', disabled = false } = Astro.props; const Tag = href ? 'a' : 'button'; --- <Tag href={href} type={href ? undefined : type} disabled={disabled} class={`shiny-btn shiny-btn--${variant} shiny-btn--${size}`} > <span class="shiny-btn__content"><slot /></span> </Tag> <style> .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; } </style>

Quick Info

Category
Buttons
Filename
ShinyButton.astro
Dependencies
None — pure Astro + CSS
Tags
buttonshineanimated