Glow Button for Astro
An Astro button with an animated glow behind the control.
Installation
bunx --bun shadcn@latest add @gnostic/glow-buttonnpx shadcn@latest add @gnostic/glow-buttonpnpm dlx shadcn@latest add @gnostic/glow-buttonInstall component packages
bun add motionnpm install motionpnpm add motionCopy the files
src/components/ui/glow-button/glow-animation.tssrc/components/ui/glow-button/glow-button-effect.astrosrc/components/ui/glow-button/glow-button.astrosrc/components/ui/glow-button/index.tssrc/components/ui/glow-button/types.ts
Usage
---
import { GlowButton } from "@/components/ui/glow-button"
---
<GlowButton>Get started</GlowButton>
GlowButton is the outer shell. It renders a Button,
a scale layer, and a glow layer. The shell script reads the glow layer and
runs the animation. The glow layer does not start its own animation.
class merges onto the button. variant, size, and withLoader use the
Button props. Set type="submit" for a form action. Without as, an href
selects an anchor. Otherwise the component renders a button with type="button".
The root uses data-slot="glow-button". The painted layer uses
data-slot="glow-button-effect".
Examples
Modes
rotate is the default. pulse and breathe change scale and color.
colorShift and flowHorizontal move through the palette. static paints
one gradient and does not loop.
Theme colors
Pass var(--primary) and other theme tokens to follow the active preset.
Use at least two colors.
Link
Use as="a" and href for a destination.
Props
GlowButtonProps
mode?GlowMode
Glow animation mode.
GlowMode"rotate"colors?string[]
Glow colors. Use at least two colors for a visible shift. A theme token such as `var(--primary)` follows the active preset.
string[]["#FF5733", "#33FF57", "#3357FF", "#F1C40F"]blur?GlowBlur
Blur strength of the glow layer.
GlowBlur"strong"duration?number
Duration of one animation cycle, in seconds.
number5glowScale?number
Scale of the glow layer relative to the button. Values above 1 spread the glow past the button edges.
number1GlowButtonEffectProps
colors?string[]
Glow colors. Use at least two colors for a visible shift.
string[]["#FF5733", "#33FF57", "#3357FF", "#F1C40F"]mode?GlowMode
Glow animation mode.
GlowMode"rotate"blur?GlowBlur
Blur strength of the glow layer.
GlowBlur"strong"scale?number
Scale of this layer before the shell hover scale. Pulse and breathe animate around this value.
number1duration?number
Duration of one animation cycle, in seconds.
number5Read the installed source for the complete prop types.
GlowButtonEffect is the painted layer. Use it only inside GlowButton.
The shell owns the animation.
Slots
Use the default slot for the visible action label.
button-loading-indicator?Astro content
Supplies a custom loading indicator. Set data-slot="button-loading-indicator" on its root to apply the Button loading styles.
Astro contentSpinner when withLoader is trueKeyboard and behavior
A native button supports Enter and Space. A link supports Enter and normal
browser link actions. The glow is decorative and is hidden from assistive
technology. disabled fades the shell and blocks pointer input. On a link,
the shell also sets aria-disabled and removes the link from the tab order.
The animation respects prefers-reduced-motion: reduce. That setting keeps
the first gradient and skips the hover scale.
Theme and layout
The button uses the shared Button recipe. The default glow palette is
independent of the preset. Pass theme tokens in colors when the glow should
follow the preset. blur selects the halo strength. glowScale above 1
spreads the halo past the button edges. Give the preview or parent some
padding so the halo is not clipped.