WebberUI

Text Hover Gradient

Outlined text filled by a gradient on hover (x.ai style), with a spotlight that follows the cursor to reveal color.

Renders the text as an SVG outline that draws itself once on mount; on hover, a gradient spotlight follows the cursor and progressively fills the outline with spectrum color.

Loading preview…
npx shadcn@latest add https://webberui.com/r/text-hover-gradient.json

Playground

Tune the props live — the code snippet updates as you go, so you can dial in the look you want before copying it.

56
0.75
0.28
3.5
<TextHoverGradient />

Installation

npx shadcn@latest add https://webberui.com/r/text-hover-gradient.json

Or, once registries are configured in components.json, install it as @webberui/text-hover-gradient.

Usage

import { TextHoverGradient } from "@/components/ui/text-hover-gradient";

<TextHoverGradient text="webber" className="text-6xl font-bold" />

Props

PropTypeDefaultDescription
textstringThe text to outline and fill (single line)
colorsstring[]alternating warm/cool spectrumGradient stop colors, laid out horizontally
strokeWidthnumber0.75Stroke width (in user units relative to the viewBox height of 100)
drawDurationnumber3.5Duration of the self-drawing outline on mount (seconds); set 0 to disable
followDurationnumber0.28How long the spotlight takes to settle onto the cursor (seconds)
spotlightstring"22%"Spotlight radius (a viewBox percentage string)
fontSizenumber56Font size (SVG user units); the text is centered in a 300x100 viewBox

Accessibility

  • When the user has "reduce motion" enabled at the system level, the self-drawing outline and spotlight animation are skipped and the complete gradient outline is shown directly
  • Scaling is handled by the viewBox, so the font size and stroke width adapt proportionally to the container

On this page