Gradient Button for Astro
A button with an animated gradient border or fill.
Installation
bunx --bun shadcn@latest add @gnostic/gradient-buttonnpx shadcn@latest add @gnostic/gradient-buttonpnpm dlx shadcn@latest add @gnostic/gradient-buttonCopy the files
src/components/ui/gradient-button/gradient-button.astrosrc/components/ui/gradient-button/index.tssrc/components/ui/gradient-button/types.ts
Usage
The default outline variant draws the gradient around the border. Use
filled to extend it across the button. Both variants use the standard
Button sizes and accept a text label or an icon.
---
import { GradientButton } from "@/components/ui/gradient-button"
---
<GradientButton href="#settings">View settings</GradientButton>
<GradientButton variant="filled" type="submit">Save changes</GradientButton>
An href selects a link. A button defaults to type="button". Give an
icon-only button an accessible name with aria-label.
Custom colors
Set from, via, and to to CSS colors or theme variables. Use class to
choose a text color that is readable against a custom fill.
<GradientButton colors={{ from: "#6d28d9", via: "#db2777", to: "#ea580c" }}>
Edit colors
</GradientButton>
The gradient moves faster on hover and keyboard focus. It stays still when the button is disabled or the user requests reduced motion.
GradientButton slots
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 trueProps
variant?'outline' | 'filled'
Apply the gradient to the border or the full button.
'outline' | 'filled''outline'colors?{ from: string; via: string; to: string }
CSS colors for the start, middle, and end of the gradient.
{ from: string; via: string; to: string }See the installable source.