Skip to content
Esc
↑↓navigate↵open⌘Jpreview
On this page

Glow Button for Astro

An Astro button with an animated glow behind the control.

Installation

bunx --bun shadcn@latest add @gnostic/glow-button

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.

Use as="a" and href for a destination.

Props

GlowButtonProps

PropType
mode?GlowMode

Glow animation mode.

TypeGlowMode
Default"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.

Typestring[]
Default["#FF5733", "#33FF57", "#3357FF", "#F1C40F"]
blur?GlowBlur

Blur strength of the glow layer.

TypeGlowBlur
Default"strong"
duration?number

Duration of one animation cycle, in seconds.

Typenumber
Default5
glowScale?number

Scale of the glow layer relative to the button. Values above 1 spread the glow past the button edges.

Typenumber
Default1

GlowButtonEffectProps

PropType
colors?string[]

Glow colors. Use at least two colors for a visible shift.

Typestring[]
Default["#FF5733", "#33FF57", "#3357FF", "#F1C40F"]
mode?GlowMode

Glow animation mode.

TypeGlowMode
Default"rotate"
blur?GlowBlur

Blur strength of the glow layer.

TypeGlowBlur
Default"strong"
scale?number

Scale of this layer before the shell hover scale. Pulse and breathe animate around this value.

Typenumber
Default1
duration?number

Duration of one animation cycle, in seconds.

Typenumber
Default5

Read 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.

PropType
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.

TypeAstro content
DefaultSpinner when withLoader is true

Keyboard 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.