Glow Card for Astro
An Astro container that paints a pointer glow on each child.
Installation
bunx --bun shadcn@latest add @gnostic/glow-cardnpx shadcn@latest add @gnostic/glow-cardpnpm dlx shadcn@latest add @gnostic/glow-cardCopy the files
src/components/ui/glow-card/glow-card.astrosrc/components/ui/glow-card/glow-card.tssrc/components/ui/glow-card/index.tssrc/components/ui/glow-card/types.ts
Usage
---
import {
Card,
CardDescription,
CardHeader,
CardTitle,
} from "@/components/ui/card"
import { GlowCard } from "@/components/ui/glow-card"
---
<GlowCard class="flex flex-wrap gap-8 p-8">
<Card>
<CardHeader>
<CardTitle>Atlas</CardTitle>
<CardDescription>Records the work in one place.</CardDescription>
</CardHeader>
</Card>
</GlowCard>
GlowCard is one container. Put each Card in the
default slot. Any other element works the same way. The component does not
set gap, direction, or alignment. Use your own layout classes. A row, a
column, and a grid all work.
The script reads each child’s position. When the pointer is within
proximity of that box, the arc on that child fades in and turns toward
the pointer.
class merges onto the container. colors, proximity, spread, blur,
and opacity set custom properties on the container style.
The root uses data-slot="glow-card". Each child receives a decorative
layer with data-slot="glow-card-glow".
Examples
Stack
The same glow follows children in a column. Give the container padding so the arc can turn on in the space around a child.
Custom colors
Pass CSS colors to replace the theme default. Use at least two colors.
Props
GlowCardProps
colors?string[]
Colors in the shared conic glow. The first color also closes the loop. The default uses the theme foreground and primary.
string[]["var(--foreground)", "var(--primary)"]proximity?number
Distance from a child edge, in pixels, that turns the glow on.
number40spread?number
Width of the bright arc, in degrees.
number60blur?number
Blur of the soft arc, in pixels.
number20opacity?number
Opacity of the glow when the pointer is outside `proximity`. `0` hides the glow until the pointer is near. `1` keeps it on.
number0Read the installed source for the complete prop types.
Slots
| Slot | Content |
|---|---|
| Default | The elements that receive the glow. |
Keyboard and behavior
The glow is decorative and is hidden from assistive technology. It follows the pointer. It does not move for keyboard focus.
prefers-reduced-motion: reduce skips pointer tracking and keeps the resting
opacity.
Theme and layout
Give each child a background, a radius, and padding. The arc uses that radius.
The soft arc can paint outside the child. A direct Card child gets
overflow-visible from the container, so the card recipe does not clip that
blur.
The child’s own ::before and ::after stay available. The glow uses a layer
inside the child.