Кнопкиbuttonglowanimatedneon
Glow Button
Кнопка с анимированным эффектом неонового свечения, пульсирующим при наведении.
Живое превью
Использование
Скопируйте и вставьте этот код в ваш React-компонент:
tsx
import { GlowButton } from 'react-component-kit-ui/buttons';
<GlowButton color="#d4a017">Glow pulse</GlowButton>Ручная установка
Если вы не используете пакет npm, создайте файл и вставьте следующий код: src/components/GlowButton.tsx + GlowButton.css:
GlowButton.tsx
'use client';
import type { CSSProperties, ElementType, HTMLAttributes, ReactNode } from 'react';
import './GlowButton.css';
/**
* GlowButton — A button with an animated glow effect that pulsates on hover.
*
* @param color - Optional. Glow color. Default '#6366f1'.
*/
export interface GlowButtonProps extends HTMLAttributes<HTMLElement> {
href?: string;
target?: string;
rel?: string;
type?: 'button' | 'submit' | 'reset';
color?: string;
size?: 'sm' | 'md' | 'lg';
disabled?: boolean;
children?: ReactNode;
}
export function GlowButton({
href,
type = 'button',
color = '#6366f1',
size = 'md',
disabled = false,
className,
style,
children,
...rest
}: GlowButtonProps) {
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={['glow-btn', `glow-btn--${size}`, className].filter(Boolean).join(' ')}
style={{ '--btn-color': color, ...style } as CSSProperties}
>
<span className="glow-btn__content">{children}</span>
</Tag>
);
}
export default GlowButton;GlowButton.css
/* GlowButton — ported from astro-component-kit (buttons/GlowButton.astro) */
.glow-btn {
--glow-color: var(--btn-color);
--glow-opacity: 0.4;
display: inline-flex;
align-items: center;
justify-content: center;
font-family: var(--font-sans, inherit);
font-weight: 700;
letter-spacing: 0.05em;
text-transform: uppercase;
color: #fff;
background: var(--btn-color);
border: none;
border-radius: 10px;
cursor: pointer;
text-decoration: none;
position: relative;
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
white-space: nowrap;
user-select: none;
z-index: 1;
/* Layered Glow */
box-shadow:
0 0 10px color-mix(in srgb, var(--glow-color), transparent 60%),
0 0 20px color-mix(in srgb, var(--glow-color), transparent 80%);
}
.glow-btn__content {
position: relative;
z-index: 2;
}
.glow-btn::before {
content: '';
position: absolute;
inset: -2px;
background: var(--btn-color);
border-radius: inherit;
z-index: -1;
opacity: 0;
filter: blur(8px);
transition: opacity 0.3s ease;
}
.glow-btn::after {
content: '';
position: absolute;
inset: -8px;
background: var(--btn-color);
border-radius: 14px;
opacity: 0;
filter: blur(25px);
transition: opacity 0.4s ease;
z-index: -2;
}
.glow-btn:hover:not(:disabled) {
transform: translateY(-3px) scale(1.03);
box-shadow:
0 0 20px color-mix(in srgb, var(--glow-color), transparent 40%),
0 0 40px color-mix(in srgb, var(--glow-color), transparent 70%);
}
.glow-btn:hover:not(:disabled)::before {
opacity: 0.4;
}
.glow-btn:hover:not(:disabled)::after {
opacity: 0.7;
animation: glow-button-animate-glow 2.5s ease-in-out infinite;
}
.glow-btn:active:not(:disabled) {
transform: translateY(1px) scale(0.98);
}
.glow-btn:disabled {
opacity: 0.5;
cursor: not-allowed;
filter: grayscale(1);
box-shadow: none;
}
@keyframes glow-button-animate-glow {
0%, 100% { opacity: 0.5; filter: blur(20px); transform: scale(1); }
50% { opacity: 0.8; filter: blur(30px); transform: scale(1.1); }
}
/* Sizes */
.glow-btn--sm { padding: 0.5rem 1.4rem; font-size: 0.75rem; }
.glow-btn--md { padding: 0.8rem 2.2rem; font-size: 0.875rem; }
.glow-btn--lg { padding: 1.1rem 3rem; font-size: 1rem; }Краткая информация
- Категория
- Кнопки
- Имя файла
GlowButton.tsx- Зависимости
- Нет — чистый React + CSS
- Теги
- buttonglowanimatedneon