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

Gradient Button for Astro

A button with an animated gradient border or fill.

Installation

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

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

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

Props

PropType
variant?'outline' | 'filled'

Apply the gradient to the border or the full button.

Type'outline' | 'filled'
Default'outline'
colors?{ from: string; via: string; to: string }

CSS colors for the start, middle, and end of the gradient.

Type{ from: string; via: string; to: string }

See the installable source.