Skip to content

UI Library for Design Engineers. Animated components and effects you can copy and paste into your apps. Free. Open Source.

feat(glare-hover): introduce Glare Hover component with demo examples (#938)

Matheus Sanofcca4da09b97
diff --git a/.gitignore b/.gitignore
index 24c49006..bbc5b281 100644
--- a/.gitignore
+++ b/.gitignore
@@ -21,6 +21,8 @@
# IDE Files
.idea
+.omc/
+.claude/settings.local.json
# debug
npm-debug.log*
diff --git a/apps/www/config/docs.ts b/apps/www/config/docs.ts
index 94373d12..5279544b 100644
--- a/apps/www/config/docs.ts
+++ b/apps/www/config/docs.ts
@@ -299,6 +299,12 @@ export const docsConfig: DocsConfig = {
href: `/docs/components/magic-card`,
items: [],
},
+ {
+ title: "Glare Hover",
+ href: `/docs/components/glare-hover`,
+ items: [],
+ label: "New",
+ },
{
title: "Meteors",
href: `/docs/components/meteors`,
diff --git a/apps/www/content/docs/components/glare-hover.mdx b/apps/www/content/docs/components/glare-hover.mdx
new file mode 100644
index 00000000..9313668d
--- /dev/null
+++ b/apps/www/content/docs/components/glare-hover.mdx
@@ -0,0 +1,140 @@
+---
+title: Glare Hover
+date: 2024-12-19
+description: A diagonal light glare on hover using a ::before gradient, CSS variables, and background-position animation—no extra global keyframes required.
+author: magicui
+published: true
+---
+
+<ComponentPreview name="glare-hover-demo" />
+
+## Examples
+
+### CTA
+
+<ComponentPreview name="glare-hover-demo-cta" />
+
+### Alerts
+
+<ComponentPreview name="glare-hover-demo-alert" />
+
+## Installation
+
+<Tabs defaultValue="cli">
+
+<TabsList>
+ <TabsTrigger value="cli">CLI</TabsTrigger>
+ <TabsTrigger value="manual">Manual</TabsTrigger>
+</TabsList>
+<TabsContent value="cli">
+
+```bash
+npx shadcn@latest add @magicui/glare-hover
+```
+
+</TabsContent>
+
+<TabsContent value="manual">
+
+<Steps>
+
+<Step>Copy and paste the following code into your project.</Step>
+
+<ComponentSource name="glare-hover" />
+
+<Step>Update the import paths to match your project setup.</Step>
+
+</Steps>
+
+</TabsContent>
+
+</Tabs>
+
+## Usage
+
+The effect is implemented with a **`::before` pseudo-element**: a `linear-gradient` tile moves from one corner to the opposite on hover. Color is parsed from **hex** (`#rgb` or `#rrggbb`) into `rgba` for the glare band.
+
+```tsx showLineNumbers
+import { GlareHover } from "@/registry/magicui/glare-hover"
+```
+
+```tsx showLineNumbers
+<GlareHover className="rounded-lg">
+ <Card>
+ <CardContent>
+ <CardTitle>Hello World</CardTitle>
+ <CardDescription>Hover to see the glare sweep</CardDescription>
+ </CardContent>
+ </Card>
+</GlareHover>
+```
+
+### Colors and opacity
+
+Use **`color`** (hex glare highlight) and **`opacity`** (alpha of that highlight). **`background`** sets the container background (default `#000`).
+
+```tsx showLineNumbers
+<GlareHover
+ className="rounded-lg"
+ color="#a78bfa"
+ opacity={0.35}
+ background="#0a0a0a"
+>
+ <Card>{/* ... */}</Card>
+</GlareHover>
+```
+
+### Angle and size
+
+**`angle`** is the gradient angle in degrees (default **-45**). **`size`** is the glare tile size as a **percentage** of the element (default **250**), passed to `background-size`.
+
+```tsx showLineNumbers
+<GlareHover className="rounded-lg" angle={-30} size={280}>
+ <Card>{/* ... */}</Card>
+</GlareHover>
+```
+
+### Duration
+
+**`duration`** is the transition length in **milliseconds** (default **650**).
+
+```tsx showLineNumbers
+<GlareHover className="rounded-lg" duration={500}>
+ <Card>{/* ... */}</Card>
+</GlareHover>
+```
+
+### playOnce
+
+With **`playOnce`** (default **false**), the glare only animates while hovering: transitions are disabled until hover, so the sweep runs each time you enter the element instead of animating on first paint.
+
+```tsx showLineNumbers
+<GlareHover className="rounded-lg" playOnce>
+ <Card>{/* ... */}</Card>
+</GlareHover>
+```
+
+### Layout
+
+Optional **`width`** and **`height`** are merged onto the root `style` (string values, e.g. `"100%"`). You can also rely on **`className`** (e.g. `w-full`) and normal `style` / `div` props.
+
+## Props
+
+### GlareHover
+
+| Prop | Type | Default | Description |
+| ------------ | ----------------- | ----------- | --------------------------------------------------------------------- |
+| `children` | `React.ReactNode` | — | Content inside the wrapper. |
+| `className` | `string` | — | Classes on the root `div` (use `rounded-*`, `overflow-hidden`, etc.). |
+| `style` | `CSSProperties` | — | Merged after CSS variables and `background`. |
+| `background` | `string` | `"#000"` | Root background color. |
+| `color` | `string` | `"#ffffff"` | Glare highlight (hex `#rgb` / `#rrggbb`). |
+| `opacity` | `number` | `0.5` | Alpha for the parsed glare color. |
+| `angle` | `number` | `-45` | Gradient angle in degrees (`--gh-angle`). |
+| `size` | `number` | `250` | Glare tile size in `%` (`--gh-size`). |
+| `duration` | `number` | `650` | Transition duration in ms (`--gh-duration`). |
+| `playOnce` | `boolean` | `false` | If `true`, animation runs on hover only (no transition until hover). |
+| `width` | `string` | — | Optional `width` on the root `style`. |
+| `height` | `string` | — | Optional `height` on the root `style`. |
+
+The root forwards standard **`div`** props (`onClick`, `data-*`, etc.). The glare is drawn on **`::before`** with `z-10` above the content.
diff --git a/apps/www/public/llms-full.txt b/apps/www/public/llms-full.txt
index 4c49bccd..a7c6c48f 100644
--- a/apps/www/public/llms-full.txt
+++ b/apps/www/public/llms-full.txt
@@ -7699,6 +7699,336 @@ export default function FlickeringGridRoundedDemo() {
+===== COMPONENT: glare-hover =====
+Title: Glare Hover
+Description: A diagonal glare on hover using a ::before gradient and CSS variables (angle, size, duration, color).
+
+--- file: magicui/glare-hover.tsx ---
+import type { ComponentProps, CSSProperties } from "react"
+import { useMemo } from "react"
+
+import { cn } from "@/lib/utils"
+
+export interface GlareHoverProps extends ComponentProps<"div"> {
+ /**
+ * Optional CSS width on the root element (e.g. `"100%"`, `"320px"`).
+ * @example
+ * ```tsx
+ * <GlareHover width="100%">...</GlareHover>
+ * ```
+ */
+ width?: string
+ /**
+ * Optional CSS height on the root element (e.g. `"auto"`, `"200px"`).
+ * @example
+ * ```tsx
+ * <GlareHover height="200px">...</GlareHover>
+ * ```
+ */
+ height?: string
+ /**
+ * Background color of the wrapper (CSS color string).
+ * @example
+ * ```tsx
+ * <GlareHover background="#0a0a0a">...</GlareHover>
+ * ```
+ */
+ background?: string
+ /**
+ * Glare highlight as `#rrggbb` or `#rgb`; parsed to `rgba` for the gradient.
+ * @example
+ * ```tsx
+ * <GlareHover color="#a78bfa">...</GlareHover>
+ * ```
+ */
+ color?: Color
+ /**
+ * Opacity applied to the glare color when converting hex to `rgba` (0–1).
+ * @example
+ * ```tsx
+ * <GlareHover color="#ffffff" opacity={0.35}>...</GlareHover>
+ * ```
+ */
+ opacity?: number
+ /**
+ * Gradient angle in degrees (`--gh-angle`).
+ * @example
+ * ```tsx
+ * <GlareHover angle={-30}>...</GlareHover>
+ * ```
+ */
+ angle?: number
+ /**
+ * Glare tile size as a percentage of the element (`--gh-size`, `background-size`).
+ * @example
+ * ```tsx
+ * <GlareHover size={280}>...</GlareHover>
+ * ```
+ */
+ size?: number
+ /**
+ * Transition duration for the glare sweep in milliseconds (`--gh-duration`).
+ * @example
+ * ```tsx
+ * <GlareHover duration={500}>...</GlareHover>
+ * ```
+ */
+ duration?: number
+ /**
+ * When `true`, the glare transition only runs on hover (no animation until pointer enters).
+ * @example
+ * ```tsx
+ * <GlareHover playOnce>...</GlareHover>
+ * ```
+ */
+ playOnce?: boolean
+}
+
+type Color = `#${string}`
+type RGBA = `rgba(${number},${number},${number},${number})`
+
+function parseHEX(color: Color, opacity: number): RGBA | Color {
+ const hex = color.replace("#", "")
+ const parse = (h: string) => Number.parseInt(h, 16)
+ if (/^[0-9A-Fa-f]{6}$/.test(hex)) {
+ return `rgba(${parse(hex.slice(0, 2))},${parse(hex.slice(2, 4))},${parse(hex.slice(4, 6))},${opacity})`
+ }
+ if (/^[0-9A-Fa-f]{3}$/.test(hex)) {
+ return `rgba(${parse(hex[0] + hex[0])},${parse(hex[1] + hex[1])},${parse(hex[2] + hex[2])},${opacity})`
+ }
+
+ return color
+}
+
+function GlareHover({
+ background = "#000",
+ children,
+ color = "#ffffff",
+ opacity = 0.5,
+ angle = -45,
+ size = 250,
+ duration = 650,
+ playOnce = false,
+ className,
+ style,
+ width,
+ height,
+ ...props
+}: GlareHoverProps) {
+ const rgba = useMemo(() => parseHEX(color, opacity), [color, opacity])
+
+ const cssVars = {
+ "--gh-angle": `${angle}deg`,
+ "--gh-duration": `${duration}ms`,
+ "--gh-size": `${size}%`,
+ "--gh-rgba": rgba,
+ background,
+ ...style,
+ ...(width !== undefined ? { width } : {}),
+ ...(height !== undefined ? { height } : {}),
+ } as CSSProperties
+
+ return (
+ <div
+ {...props}
+ className={cn(
+ "relative grid size-fit cursor-pointer place-items-center overflow-hidden bg-transparent",
+ // BEFORE ELEMENT
+ "before:pointer-events-none before:absolute before:inset-0 before:z-10 before:bg-no-repeat before:content-['']",
+ // GRADIENT
+ "before:[background-image:linear-gradient(var(--gh-angle),transparent_60%,var(--gh-rgba)_70%,transparent,transparent_100%)]",
+ // SIZE + POSITION
+ "before:[background-size:var(--gh-size)_var(--gh-size),100%_100%]",
+ "before:[background-position:-100%_-100%,0_0]",
+ // TRANSITION
+ !playOnce &&
+ "before:transition-[background-position] before:duration-[var(--gh-duration)] before:ease-in-out",
+ playOnce &&
+ "before:transition-none hover:before:transition-[background-position] hover:before:duration-[var(--gh-duration)]",
+ // HOVER EFFECT
+ "hover:before:[background-position:100%_100%,0_0]",
+ className
+ )}
+ style={cssVars}
+ >
+ {children}
+ </div>
+ )
+}
+
+export { GlareHover }
+
+
+===== EXAMPLE: glare-hover-demo =====
+Title: Glare Hover Demo
+
+--- file: example/glare-hover-demo.tsx ---
+import { Badge } from "@/components/ui/badge"
+import { Button } from "@/components/ui/button"
+import {
+ Card,
+ CardContent,
+ CardDescription,
+ CardFooter,
+ CardHeader,
+ CardTitle,
+} from "@/components/ui/card"
+import { GlareHover } from "@/registry/magicui/glare-hover"
+
+export default function PricingCard() {
+ return (
+ <GlareHover className="rounded-xl" duration={600}>
+ <Card className="w-[340px]">
+ <CardHeader>
+ <div className="flex items-center justify-between">
+ <CardTitle>Pro</CardTitle>
+ <Badge>Popular</Badge>
+ </div>
+ <CardDescription>For teams that need more.</CardDescription>
+ <div className="flex items-baseline gap-1 pt-2">
+ <span className="text-4xl font-semibold tracking-tight">$49</span>
+ <span className="text-muted-foreground text-sm">/mo</span>
+ </div>
+ </CardHeader>
+ <CardContent className="flex flex-col gap-2.5">
+ {[
+ "Unlimited projects",
+ "Team collaboration",
+ "Advanced analytics",
+ ].map((f) => (
+ <div key={f} className="flex items-center gap-2 text-sm">
+ <svg width="15" height="15" viewBox="0 0 15 15" fill="none">
+ <path
+ d="M12.5 3.5L6 10L2.5 6.5"
+ stroke="currentColor"
+ strokeWidth="1.5"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ />
+ </svg>
+ {f}
+ </div>
+ ))}
+ <div className="text-muted-foreground flex items-center gap-2 text-sm">
+ <svg width="15" height="15" viewBox="0 0 15 15" fill="none">
+ <circle
+ cx="7.5"
+ cy="7.5"
+ r="1.5"
+ fill="currentColor"
+ opacity="0.4"
+ />
+ </svg>
+ SSO (coming soon)
+ </div>
+ </CardContent>
+ <CardFooter>
+ <Button className="w-full">Get started</Button>
+ </CardFooter>
+ </Card>
+ </GlareHover>
+ )
+}
+
+
+===== EXAMPLE: glare-hover-demo-cta =====
+Title: Glare Hover Demo — CTA
+
+--- file: example/glare-hover-demo-cta.tsx ---
+import { Button } from "@/components/ui/button"
+import {
+ Card,
+ CardDescription,
+ CardFooter,
+ CardHeader,
+ CardTitle,
+} from "@/components/ui/card"
+import { GlareHover } from "@/registry/magicui/glare-hover"
+
+export default function Cta() {
+ return (
+ <GlareHover className="rounded-xl" color="#505050" duration={700}>
+ <Card className="w-full text-center">
+ <CardHeader>
+ <p className="text-muted-foreground text-xs font-medium tracking-widest uppercase">
+ 14-day free trial · No card required
+ </p>
+ <CardTitle className="text-2xl tracking-tight">
+ Ready to get started?
+ </CardTitle>
+ <CardDescription className="mx-auto max-w-sm">
+ Join 4,000+ teams already using our platform to ship faster.
+ </CardDescription>
+ </CardHeader>
+ <CardFooter className="justify-center gap-2">
+ <Button>Start free trial</Button>
+ <Button variant="outline">View demo</Button>
+ </CardFooter>
+ </Card>
+ </GlareHover>
+ )
+}
+
+
+===== EXAMPLE: glare-hover-demo-alert =====
+Title: Glare Hover Demo — Alerts
+
+--- file: example/glare-hover-demo-alert.tsx ---
+import { CheckCircleIcon, InfoIcon, TriangleAlertIcon } from "lucide-react"
+
+import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"
+import { GlareHover } from "@/registry/magicui/glare-hover"
+
+export default function Alerts() {
+ return (
+ <div className="flex flex-col gap-3">
+ <GlareHover className="rounded-lg" duration={550} opacity={0.25}>
+ <Alert className="[&>svg~*]:pl-10">
+ <InfoIcon />
+ <AlertTitle>Action required</AlertTitle>
+ <AlertDescription>
+ Your plan expires in 3 days. Renew to keep access.
+ </AlertDescription>
+ </Alert>
+ </GlareHover>
+
+ <GlareHover
+ className="w-full rounded-lg"
+ color="#ff6070"
+ opacity={0.25}
+ duration={550}
+ >
+ <Alert variant="destructive" className="bg-background [&>svg~*]:pl-10">
+ <TriangleAlertIcon />
+ <AlertTitle>Payment declined</AlertTitle>
+ <AlertDescription>
+ Check your card details and try again.
+ </AlertDescription>
+ </Alert>
+ </GlareHover>
+
+ <GlareHover
+ className="w-full rounded-lg"
+ color="#60ff70"
+ opacity={0.25}
+ duration={550}
+ >
+ <Alert className="[&>svg~*]:pl-10">
+ <CheckCircleIcon className="stroke-emerald-500" />
+ <AlertTitle className="text-emerald-500">
+ Subscription confirmed
+ </AlertTitle>
+ <AlertDescription className="text-emerald-500">
+ You have full Pro access until April 5, 2027.
+ </AlertDescription>
+ </Alert>
+ </GlareHover>
+ </div>
+ )
+}
+
+
+
===== COMPONENT: globe =====
Title: Globe
Description: An autorotating, interactive, and highly performant globe made using WebGL.
diff --git a/apps/www/public/llms.txt b/apps/www/public/llms.txt
index ffbd983a..77d58e16 100644
--- a/apps/www/public/llms.txt
+++ b/apps/www/public/llms.txt
@@ -30,6 +30,7 @@ This file provides LLM-friendly entry points to documentation and examples.
- [Dotted Map](https://magicui.design/docs/components/dotted-map): A component with a dotted map.
- [File Tree](https://magicui.design/docs/components/file-tree): A component used to showcase the folder and file structure of a directory.
- [Flickering Grid](https://magicui.design/docs/components/flickering-grid): A flickering grid background made with SVGs, fully customizable using Tailwind CSS.
+- [Glare Hover](https://magicui.design/docs/components/glare-hover): A diagonal glare on hover using a ::before gradient and CSS variables (angle, size, duration, color).
- [Globe](https://magicui.design/docs/components/globe): An autorotating, interactive, and highly performant globe made using WebGL.
- [Grid Pattern](https://magicui.design/docs/components/grid-pattern): A background grid pattern made with SVGs, fully customizable using Tailwind CSS.
- [Hero Video Dialog](https://magicui.design/docs/components/hero-video-dialog): A hero video dialog component.
@@ -116,6 +117,9 @@ This file provides LLM-friendly entry points to documentation and examples.
- [Marquee Logos](https://github.com/magicuidesign/magicui/blob/main/example/marquee-logos.tsx): Example usage
- [Marquee 3D](https://github.com/magicuidesign/magicui/blob/main/example/marquee-3d.tsx): Example usage
- [Globe Demo](https://github.com/magicuidesign/magicui/blob/main/example/globe-demo.tsx): Example usage
+- [Glare Hover Demo](https://github.com/magicuidesign/magicui/blob/main/example/glare-hover-demo.tsx): Example usage
+- [Glare Hover Demo — CTA](https://github.com/magicuidesign/magicui/blob/main/example/glare-hover-demo-cta.tsx): Example usage
+- [Glare Hover Demo — Alerts](https://github.com/magicuidesign/magicui/blob/main/example/glare-hover-demo-alert.tsx): Example usage
- [Tweet Card Demo](https://github.com/magicuidesign/magicui/blob/main/example/tweet-card-demo.tsx): Example usage
- [Tweet Card Images](https://github.com/magicuidesign/magicui/blob/main/example/tweet-card-images.tsx): Example usage
- [Tweet Card Meta Preview](https://github.com/magicuidesign/magicui/blob/main/example/tweet-card-meta-preview.tsx): Example usage
diff --git a/apps/www/public/r/glare-hover-demo-alert.json b/apps/www/public/r/glare-hover-demo-alert.json
new file mode 100644
index 00000000..1df3ba84
--- /dev/null
+++ b/apps/www/public/r/glare-hover-demo-alert.json
@@ -0,0 +1,17 @@
+{
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
+ "name": "glare-hover-demo-alert",
+ "type": "registry:example",
+ "title": "Glare Hover Demo — Alerts",
+ "description": "Three alerts with custom glare colors and opacity.",
+ "registryDependencies": [
+ "@magicui/glare-hover"
+ ],
+ "files": [
+ {
+ "path": "registry/example/glare-hover-demo-alert.tsx",
+ "content": "import { CheckCircleIcon, InfoIcon, TriangleAlertIcon } from \"lucide-react\"\n\nimport { Alert, AlertDescription, AlertTitle } from \"@/components/ui/alert\"\nimport { GlareHover } from \"@/registry/magicui/glare-hover\"\n\nexport default function Alerts() {\n return (\n <div className=\"flex flex-col gap-3\">\n <GlareHover className=\"rounded-lg\" duration={550} opacity={0.25}>\n <Alert className=\"[&>svg~*]:pl-10\">\n <InfoIcon />\n <AlertTitle>Action required</AlertTitle>\n <AlertDescription>\n Your plan expires in 3 days. Renew to keep access.\n </AlertDescription>\n </Alert>\n </GlareHover>\n\n <GlareHover\n className=\"w-full rounded-lg\"\n color=\"#ff6070\"\n opacity={0.25}\n duration={550}\n >\n <Alert variant=\"destructive\" className=\"bg-background [&>svg~*]:pl-10\">\n <TriangleAlertIcon />\n <AlertTitle>Payment declined</AlertTitle>\n <AlertDescription>\n Check your card details and try again.\n </AlertDescription>\n </Alert>\n </GlareHover>\n\n <GlareHover\n className=\"w-full rounded-lg\"\n color=\"#60ff70\"\n opacity={0.25}\n duration={550}\n >\n <Alert className=\"[&>svg~*]:pl-10\">\n <CheckCircleIcon className=\"stroke-emerald-500\" />\n <AlertTitle className=\"text-emerald-500\">\n Subscription confirmed\n </AlertTitle>\n <AlertDescription className=\"text-emerald-500\">\n You have full Pro access until April 5, 2027.\n </AlertDescription>\n </Alert>\n </GlareHover>\n </div>\n )\n}\n",
+ "type": "registry:example"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/apps/www/public/r/glare-hover-demo-cta.json b/apps/www/public/r/glare-hover-demo-cta.json
new file mode 100644
index 00000000..e22de31a
--- /dev/null
+++ b/apps/www/public/r/glare-hover-demo-cta.json
@@ -0,0 +1,17 @@
+{
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
+ "name": "glare-hover-demo-cta",
+ "type": "registry:example",
+ "title": "Glare Hover Demo — CTA",
+ "description": "CTA card with hover glare (700ms).",
+ "registryDependencies": [
+ "@magicui/glare-hover"
+ ],
+ "files": [
+ {
+ "path": "registry/example/glare-hover-demo-cta.tsx",
+ "content": "import { Button } from \"@/components/ui/button\"\nimport {\n Card,\n CardDescription,\n CardFooter,\n CardHeader,\n CardTitle,\n} from \"@/components/ui/card\"\nimport { GlareHover } from \"@/registry/magicui/glare-hover\"\n\nexport default function Cta() {\n return (\n <GlareHover className=\"rounded-xl\" color=\"#505050\" duration={700}>\n <Card className=\"w-full text-center\">\n <CardHeader>\n <p className=\"text-muted-foreground text-xs font-medium tracking-widest uppercase\">\n 14-day free trial · No card required\n </p>\n <CardTitle className=\"text-2xl tracking-tight\">\n Ready to get started?\n </CardTitle>\n <CardDescription className=\"mx-auto max-w-sm\">\n Join 4,000+ teams already using our platform to ship faster.\n </CardDescription>\n </CardHeader>\n <CardFooter className=\"justify-center gap-2\">\n <Button>Start free trial</Button>\n <Button variant=\"outline\">View demo</Button>\n </CardFooter>\n </Card>\n </GlareHover>\n )\n}\n",
+ "type": "registry:example"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/apps/www/public/r/glare-hover-demo.json b/apps/www/public/r/glare-hover-demo.json
new file mode 100644
index 00000000..212a576c
--- /dev/null
+++ b/apps/www/public/r/glare-hover-demo.json
@@ -0,0 +1,17 @@
+{
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
+ "name": "glare-hover-demo",
+ "type": "registry:example",
+ "title": "Glare Hover Demo",
+ "description": "Pricing card with diagonal hover glare (duration 600ms).",
+ "registryDependencies": [
+ "@magicui/glare-hover"
+ ],
+ "files": [
+ {
+ "path": "registry/example/glare-hover-demo.tsx",
+ "content": "import { Badge } from \"@/components/ui/badge\"\nimport { Button } from \"@/components/ui/button\"\nimport {\n Card,\n CardContent,\n CardDescription,\n CardFooter,\n CardHeader,\n CardTitle,\n} from \"@/components/ui/card\"\nimport { GlareHover } from \"@/registry/magicui/glare-hover\"\n\nexport default function PricingCard() {\n return (\n <GlareHover className=\"rounded-xl\" duration={600}>\n <Card className=\"w-[340px]\">\n <CardHeader>\n <div className=\"flex items-center justify-between\">\n <CardTitle>Pro</CardTitle>\n <Badge>Popular</Badge>\n </div>\n <CardDescription>For teams that need more.</CardDescription>\n <div className=\"flex items-baseline gap-1 pt-2\">\n <span className=\"text-4xl font-semibold tracking-tight\">$49</span>\n <span className=\"text-muted-foreground text-sm\">/mo</span>\n </div>\n </CardHeader>\n <CardContent className=\"flex flex-col gap-2.5\">\n {[\n \"Unlimited projects\",\n \"Team collaboration\",\n \"Advanced analytics\",\n ].map((f) => (\n <div key={f} className=\"flex items-center gap-2 text-sm\">\n <svg width=\"15\" height=\"15\" viewBox=\"0 0 15 15\" fill=\"none\">\n <path\n d=\"M12.5 3.5L6 10L2.5 6.5\"\n stroke=\"currentColor\"\n strokeWidth=\"1.5\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n {f}\n </div>\n ))}\n <div className=\"text-muted-foreground flex items-center gap-2 text-sm\">\n <svg width=\"15\" height=\"15\" viewBox=\"0 0 15 15\" fill=\"none\">\n <circle\n cx=\"7.5\"\n cy=\"7.5\"\n r=\"1.5\"\n fill=\"currentColor\"\n opacity=\"0.4\"\n />\n </svg>\n SSO (coming soon)\n </div>\n </CardContent>\n <CardFooter>\n <Button className=\"w-full\">Get started</Button>\n </CardFooter>\n </Card>\n </GlareHover>\n )\n}\n",
+ "type": "registry:example"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/apps/www/public/r/glare-hover.json b/apps/www/public/r/glare-hover.json
new file mode 100644
index 00000000..1717219a
--- /dev/null
+++ b/apps/www/public/r/glare-hover.json
@@ -0,0 +1,14 @@
+{
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
+ "name": "glare-hover",
+ "type": "registry:ui",
+ "title": "Glare Hover",
+ "description": "A diagonal glare on hover using a ::before gradient and CSS variables (angle, size, duration, color).",
+ "files": [
+ {
+ "path": "registry/magicui/glare-hover.tsx",
+ "content": "import type { ComponentProps, CSSProperties } from \"react\"\nimport { useMemo } from \"react\"\n\nimport { cn } from \"@/lib/utils\"\n\nexport interface GlareHoverProps extends ComponentProps<\"div\"> {\n /**\n * Optional CSS width on the root element (e.g. `\"100%\"`, `\"320px\"`).\n * @example\n * ```tsx\n * <GlareHover width=\"100%\">...</GlareHover>\n * ```\n */\n width?: string\n /**\n * Optional CSS height on the root element (e.g. `\"auto\"`, `\"200px\"`).\n * @example\n * ```tsx\n * <GlareHover height=\"200px\">...</GlareHover>\n * ```\n */\n height?: string\n /**\n * Background color of the wrapper (CSS color string).\n * @example\n * ```tsx\n * <GlareHover background=\"#0a0a0a\">...</GlareHover>\n * ```\n */\n background?: string\n /**\n * Glare highlight as `#rrggbb` or `#rgb`; parsed to `rgba` for the gradient.\n * @example\n * ```tsx\n * <GlareHover color=\"#a78bfa\">...</GlareHover>\n * ```\n */\n color?: Color\n /**\n * Opacity applied to the glare color when converting hex to `rgba` (0–1).\n * @example\n * ```tsx\n * <GlareHover color=\"#ffffff\" opacity={0.35}>...</GlareHover>\n * ```\n */\n opacity?: number\n /**\n * Gradient angle in degrees (`--gh-angle`).\n * @example\n * ```tsx\n * <GlareHover angle={-30}>...</GlareHover>\n * ```\n */\n angle?: number\n /**\n * Glare tile size as a percentage of the element (`--gh-size`, `background-size`).\n * @example\n * ```tsx\n * <GlareHover size={280}>...</GlareHover>\n * ```\n */\n size?: number\n /**\n * Transition duration for the glare sweep in milliseconds (`--gh-duration`).\n * @example\n * ```tsx\n * <GlareHover duration={500}>...</GlareHover>\n * ```\n */\n duration?: number\n /**\n * When `true`, the glare transition only runs on hover (no animation until pointer enters).\n * @example\n * ```tsx\n * <GlareHover playOnce>...</GlareHover>\n * ```\n */\n playOnce?: boolean\n}\n\ntype Color = `#${string}`\ntype RGBA = `rgba(${number},${number},${number},${number})`\n\nfunction parseHEX(color: Color, opacity: number): RGBA | Color {\n const hex = color.replace(\"#\", \"\")\n const parse = (h: string) => Number.parseInt(h, 16)\n if (/^[0-9A-Fa-f]{6}$/.test(hex)) {\n return `rgba(${parse(hex.slice(0, 2))},${parse(hex.slice(2, 4))},${parse(hex.slice(4, 6))},${opacity})`\n }\n if (/^[0-9A-Fa-f]{3}$/.test(hex)) {\n return `rgba(${parse(hex[0] + hex[0])},${parse(hex[1] + hex[1])},${parse(hex[2] + hex[2])},${opacity})`\n }\n\n return color\n}\n\nfunction GlareHover({\n background = \"#000\",\n children,\n color = \"#ffffff\",\n opacity = 0.5,\n angle = -45,\n size = 250,\n duration = 650,\n playOnce = false,\n className,\n style,\n width,\n height,\n ...props\n}: GlareHoverProps) {\n const rgba = useMemo(() => parseHEX(color, opacity), [color, opacity])\n\n const cssVars = {\n \"--gh-angle\": `${angle}deg`,\n \"--gh-duration\": `${duration}ms`,\n \"--gh-size\": `${size}%`,\n \"--gh-rgba\": rgba,\n background,\n ...style,\n ...(width !== undefined ? { width } : {}),\n ...(height !== undefined ? { height } : {}),\n } as CSSProperties\n\n return (\n <div\n {...props}\n className={cn(\n \"relative grid size-fit cursor-pointer place-items-center overflow-hidden bg-transparent\",\n // BEFORE ELEMENT\n \"before:pointer-events-none before:absolute before:inset-0 before:z-10 before:bg-no-repeat before:content-['']\",\n // GRADIENT\n \"before:[background-image:linear-gradient(var(--gh-angle),transparent_60%,var(--gh-rgba)_70%,transparent,transparent_100%)]\",\n // SIZE + POSITION\n \"before:[background-size:var(--gh-size)_var(--gh-size),100%_100%]\",\n \"before:[background-position:-100%_-100%,0_0]\",\n // TRANSITION\n !playOnce &&\n \"before:transition-[background-position] before:duration-[var(--gh-duration)] before:ease-in-out\",\n playOnce &&\n \"before:transition-none hover:before:transition-[background-position] hover:before:duration-[var(--gh-duration)]\",\n // HOVER EFFECT\n \"hover:before:[background-position:100%_100%,0_0]\",\n className\n )}\n style={cssVars}\n >\n {children}\n </div>\n )\n}\n\nexport { GlareHover }\n",
+ "type": "registry:ui"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/apps/www/public/r/registry.json b/apps/www/public/r/registry.json
index 197f12eb..9fe4a142 100644
--- a/apps/www/public/r/registry.json
+++ b/apps/www/public/r/registry.json
@@ -418,6 +418,18 @@
}
]
},
+ {
+ "name": "glare-hover",
+ "type": "registry:ui",
+ "title": "Glare Hover",
+ "description": "A diagonal glare on hover using a ::before gradient and CSS variables (angle, size, duration, color).",
+ "files": [
+ {
+ "path": "registry/magicui/glare-hover.tsx",
+ "type": "registry:ui"
+ }
+ ]
+ },
{
"name": "shimmer-button",
"type": "registry:ui",
@@ -1832,6 +1844,51 @@
}
]
},
+ {
+ "name": "glare-hover-demo",
+ "type": "registry:example",
+ "title": "Glare Hover Demo",
+ "description": "Pricing card with diagonal hover glare (duration 600ms).",
+ "registryDependencies": [
+ "@magicui/glare-hover"
+ ],
+ "files": [
+ {
+ "path": "registry/example/glare-hover-demo.tsx",
+ "type": "registry:example"
+ }
+ ]
+ },
+ {
+ "name": "glare-hover-demo-cta",
+ "type": "registry:example",
+ "title": "Glare Hover Demo — CTA",
+ "description": "CTA card with hover glare (700ms).",
+ "registryDependencies": [
+ "@magicui/glare-hover"
+ ],
+ "files": [
+ {
+ "path": "registry/example/glare-hover-demo-cta.tsx",
+ "type": "registry:example"
+ }
+ ]
+ },
+ {
+ "name": "glare-hover-demo-alert",
+ "type": "registry:example",
+ "title": "Glare Hover Demo — Alerts",
+ "description": "Three alerts with custom glare colors and opacity.",
+ "registryDependencies": [
+ "@magicui/glare-hover"
+ ],
+ "files": [
+ {
+ "path": "registry/example/glare-hover-demo-alert.tsx",
+ "type": "registry:example"
+ }
+ ]
+ },
{
"name": "tweet-card-demo",
"type": "registry:example",
diff --git a/apps/www/public/registry.json b/apps/www/public/registry.json
index 197f12eb..9fe4a142 100644
--- a/apps/www/public/registry.json
+++ b/apps/www/public/registry.json
@@ -418,6 +418,18 @@
}
]
},
+ {
+ "name": "glare-hover",
+ "type": "registry:ui",
+ "title": "Glare Hover",
+ "description": "A diagonal glare on hover using a ::before gradient and CSS variables (angle, size, duration, color).",
+ "files": [
+ {
+ "path": "registry/magicui/glare-hover.tsx",
+ "type": "registry:ui"
+ }
+ ]
+ },
{
"name": "shimmer-button",
"type": "registry:ui",
@@ -1832,6 +1844,51 @@
}
]
},
+ {
+ "name": "glare-hover-demo",
+ "type": "registry:example",
+ "title": "Glare Hover Demo",
+ "description": "Pricing card with diagonal hover glare (duration 600ms).",
+ "registryDependencies": [
+ "@magicui/glare-hover"
+ ],
+ "files": [
+ {
+ "path": "registry/example/glare-hover-demo.tsx",
+ "type": "registry:example"
+ }
+ ]
+ },
+ {
+ "name": "glare-hover-demo-cta",
+ "type": "registry:example",
+ "title": "Glare Hover Demo — CTA",
+ "description": "CTA card with hover glare (700ms).",
+ "registryDependencies": [
+ "@magicui/glare-hover"
+ ],
+ "files": [
+ {
+ "path": "registry/example/glare-hover-demo-cta.tsx",
+ "type": "registry:example"
+ }
+ ]
+ },
+ {
+ "name": "glare-hover-demo-alert",
+ "type": "registry:example",
+ "title": "Glare Hover Demo — Alerts",
+ "description": "Three alerts with custom glare colors and opacity.",
+ "registryDependencies": [
+ "@magicui/glare-hover"
+ ],
+ "files": [
+ {
+ "path": "registry/example/glare-hover-demo-alert.tsx",
+ "type": "registry:example"
+ }
+ ]
+ },
{
"name": "tweet-card-demo",
"type": "registry:example",
diff --git a/apps/www/registry.json b/apps/www/registry.json
index 197f12eb..9fe4a142 100644
--- a/apps/www/registry.json
+++ b/apps/www/registry.json
@@ -418,6 +418,18 @@
}
]
},
+ {
+ "name": "glare-hover",
+ "type": "registry:ui",
+ "title": "Glare Hover",
+ "description": "A diagonal glare on hover using a ::before gradient and CSS variables (angle, size, duration, color).",
+ "files": [
+ {
+ "path": "registry/magicui/glare-hover.tsx",
+ "type": "registry:ui"
+ }
+ ]
+ },
{
"name": "shimmer-button",
"type": "registry:ui",
@@ -1832,6 +1844,51 @@
}
]
},
+ {
+ "name": "glare-hover-demo",
+ "type": "registry:example",
+ "title": "Glare Hover Demo",
+ "description": "Pricing card with diagonal hover glare (duration 600ms).",
+ "registryDependencies": [
+ "@magicui/glare-hover"
+ ],
+ "files": [
+ {
+ "path": "registry/example/glare-hover-demo.tsx",
+ "type": "registry:example"
+ }
+ ]
+ },
+ {
+ "name": "glare-hover-demo-cta",
+ "type": "registry:example",
+ "title": "Glare Hover Demo — CTA",
+ "description": "CTA card with hover glare (700ms).",
+ "registryDependencies": [
+ "@magicui/glare-hover"
+ ],
+ "files": [
+ {
+ "path": "registry/example/glare-hover-demo-cta.tsx",
+ "type": "registry:example"
+ }
+ ]
+ },
+ {
+ "name": "glare-hover-demo-alert",
+ "type": "registry:example",
+ "title": "Glare Hover Demo — Alerts",
+ "description": "Three alerts with custom glare colors and opacity.",
+ "registryDependencies": [
+ "@magicui/glare-hover"
+ ],
+ "files": [
+ {
+ "path": "registry/example/glare-hover-demo-alert.tsx",
+ "type": "registry:example"
+ }
+ ]
+ },
{
"name": "tweet-card-demo",
"type": "registry:example",
diff --git a/apps/www/registry/__index__.tsx b/apps/www/registry/__index__.tsx
index b3c0ec9e..ea1a3e47 100644
--- a/apps/www/registry/__index__.tsx
+++ b/apps/www/registry/__index__.tsx
@@ -389,6 +389,23 @@ export const Index: Record<string, any> = {
}),
meta: undefined,
},
+ "glare-hover": {
+ name: "glare-hover",
+ description: "A diagonal glare on hover using a ::before gradient and CSS variables (angle, size, duration, color).",
+ type: "registry:ui",
+ registryDependencies: undefined,
+ files: [{
+ path: "registry/magicui/glare-hover.tsx",
+ type: "registry:ui",
+ target: ""
+ }],
+ component: React.lazy(async () => {
+ const mod = await import("@/registry/magicui/glare-hover.tsx")
+ const exportName = Object.keys(mod).find(key => typeof mod[key] === 'function' || typeof mod[key] === 'object') ?? item.name
+ return { default: mod.default ?? mod[exportName] }
+ }),
+ meta: undefined,
+ },
"shimmer-button": {
name: "shimmer-button",
description: "A button with a shimmering light which travels around the perimeter.",
@@ -1834,6 +1851,57 @@ export const Index: Record<string, any> = {
}),
meta: undefined,
},
+ "glare-hover-demo": {
+ name: "glare-hover-demo",
+ description: "Pricing card with diagonal hover glare (duration 600ms).",
+ type: "registry:example",
+ registryDependencies: ["@magicui/glare-hover"],
+ files: [{
+ path: "registry/example/glare-hover-demo.tsx",
+ type: "registry:example",
+ target: ""
+ }],
+ component: React.lazy(async () => {
+ const mod = await import("@/registry/example/glare-hover-demo.tsx")
+ const exportName = Object.keys(mod).find(key => typeof mod[key] === 'function' || typeof mod[key] === 'object') ?? item.name
+ return { default: mod.default ?? mod[exportName] }
+ }),
+ meta: undefined,
+ },
+ "glare-hover-demo-cta": {
+ name: "glare-hover-demo-cta",
+ description: "CTA card with hover glare (700ms).",
+ type: "registry:example",
+ registryDependencies: ["@magicui/glare-hover"],
+ files: [{
+ path: "registry/example/glare-hover-demo-cta.tsx",
+ type: "registry:example",
+ target: ""
+ }],
+ component: React.lazy(async () => {
+ const mod = await import("@/registry/example/glare-hover-demo-cta.tsx")
+ const exportName = Object.keys(mod).find(key => typeof mod[key] === 'function' || typeof mod[key] === 'object') ?? item.name
+ return { default: mod.default ?? mod[exportName] }
+ }),
+ meta: undefined,
+ },
+ "glare-hover-demo-alert": {
+ name: "glare-hover-demo-alert",
+ description: "Three alerts with custom glare colors and opacity.",
+ type: "registry:example",
+ registryDependencies: ["@magicui/glare-hover"],
+ files: [{
+ path: "registry/example/glare-hover-demo-alert.tsx",
+ type: "registry:example",
+ target: ""
+ }],
+ component: React.lazy(async () => {
+ const mod = await import("@/registry/example/glare-hover-demo-alert.tsx")
+ const exportName = Object.keys(mod).find(key => typeof mod[key] === 'function' || typeof mod[key] === 'object') ?? item.name
+ return { default: mod.default ?? mod[exportName] }
+ }),
+ meta: undefined,
+ },
"tweet-card-demo": {
name: "tweet-card-demo",
description: "Example showing a tweet card with author info.",
diff --git a/apps/www/registry/example/glare-hover-demo-alert.tsx b/apps/www/registry/example/glare-hover-demo-alert.tsx
new file mode 100644
index 00000000..87c22432
--- /dev/null
+++ b/apps/www/registry/example/glare-hover-demo-alert.tsx
@@ -0,0 +1,52 @@
+import { CheckCircleIcon, InfoIcon, TriangleAlertIcon } from "lucide-react"
+
+import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"
+import { GlareHover } from "@/registry/magicui/glare-hover"
+
+export default function Alerts() {
+ return (
+ <div className="flex flex-col gap-3">
+ <GlareHover className="rounded-lg" duration={550} opacity={0.25}>
+ <Alert className="[&>svg~*]:pl-10">
+ <InfoIcon />
+ <AlertTitle>Action required</AlertTitle>
+ <AlertDescription>
+ Your plan expires in 3 days. Renew to keep access.
+ </AlertDescription>
+ </Alert>
+ </GlareHover>
+
+ <GlareHover
+ className="w-full rounded-lg"
+ color="#ff6070"
+ opacity={0.25}
+ duration={550}
+ >
+ <Alert variant="destructive" className="bg-background [&>svg~*]:pl-10">
+ <TriangleAlertIcon />
+ <AlertTitle>Payment declined</AlertTitle>
+ <AlertDescription>
+ Check your card details and try again.
+ </AlertDescription>
+ </Alert>
+ </GlareHover>
+
+ <GlareHover
+ className="w-full rounded-lg"
+ color="#60ff70"
+ opacity={0.25}
+ duration={550}
+ >
+ <Alert className="[&>svg~*]:pl-10">
+ <CheckCircleIcon className="stroke-emerald-500" />
+ <AlertTitle className="text-emerald-500">
+ Subscription confirmed
+ </AlertTitle>
+ <AlertDescription className="text-emerald-500">
+ You have full Pro access until April 5, 2027.
+ </AlertDescription>
+ </Alert>
+ </GlareHover>
+ </div>
+ )
+}
diff --git a/apps/www/registry/example/glare-hover-demo-cta.tsx b/apps/www/registry/example/glare-hover-demo-cta.tsx
new file mode 100644
index 00000000..f49c48c2
--- /dev/null
+++ b/apps/www/registry/example/glare-hover-demo-cta.tsx
@@ -0,0 +1,33 @@
+import { Button } from "@/components/ui/button"
+import {
+ Card,
+ CardDescription,
+ CardFooter,
+ CardHeader,
+ CardTitle,
+} from "@/components/ui/card"
+import { GlareHover } from "@/registry/magicui/glare-hover"
+
+export default function Cta() {
+ return (
+ <GlareHover className="rounded-xl" color="#505050" duration={700}>
+ <Card className="w-full text-center">
+ <CardHeader>
+ <p className="text-muted-foreground text-xs font-medium tracking-widest uppercase">
+ 14-day free trial · No card required
+ </p>
+ <CardTitle className="text-2xl tracking-tight">
+ Ready to get started?
+ </CardTitle>
+ <CardDescription className="mx-auto max-w-sm">
+ Join 4,000+ teams already using our platform to ship faster.
+ </CardDescription>
+ </CardHeader>
+ <CardFooter className="justify-center gap-2">
+ <Button>Start free trial</Button>
+ <Button variant="outline">View demo</Button>
+ </CardFooter>
+ </Card>
+ </GlareHover>
+ )
+}
diff --git a/apps/www/registry/example/glare-hover-demo.tsx b/apps/www/registry/example/glare-hover-demo.tsx
new file mode 100644
index 00000000..5e21a763
--- /dev/null
+++ b/apps/www/registry/example/glare-hover-demo.tsx
@@ -0,0 +1,66 @@
+import { Badge } from "@/components/ui/badge"
+import { Button } from "@/components/ui/button"
+import {
+ Card,
+ CardContent,
+ CardDescription,
+ CardFooter,
+ CardHeader,
+ CardTitle,
+} from "@/components/ui/card"
+import { GlareHover } from "@/registry/magicui/glare-hover"
+
+export default function PricingCard() {
+ return (
+ <GlareHover className="rounded-xl" duration={600}>
+ <Card className="w-[340px]">
+ <CardHeader>
+ <div className="flex items-center justify-between">
+ <CardTitle>Pro</CardTitle>
+ <Badge>Popular</Badge>
+ </div>
+ <CardDescription>For teams that need more.</CardDescription>
+ <div className="flex items-baseline gap-1 pt-2">
+ <span className="text-4xl font-semibold tracking-tight">$49</span>
+ <span className="text-muted-foreground text-sm">/mo</span>
+ </div>
+ </CardHeader>
+ <CardContent className="flex flex-col gap-2.5">
+ {[
+ "Unlimited projects",
+ "Team collaboration",
+ "Advanced analytics",
+ ].map((f) => (
+ <div key={f} className="flex items-center gap-2 text-sm">
+ <svg width="15" height="15" viewBox="0 0 15 15" fill="none">
+ <path
+ d="M12.5 3.5L6 10L2.5 6.5"
+ stroke="currentColor"
+ strokeWidth="1.5"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ />
+ </svg>
+ {f}
+ </div>
+ ))}
+ <div className="text-muted-foreground flex items-center gap-2 text-sm">
+ <svg width="15" height="15" viewBox="0 0 15 15" fill="none">
+ <circle
+ cx="7.5"
+ cy="7.5"
+ r="1.5"
+ fill="currentColor"
+ opacity="0.4"
+ />
+ </svg>
+ SSO (coming soon)
+ </div>
+ </CardContent>
+ <CardFooter>
+ <Button className="w-full">Get started</Button>
+ </CardFooter>
+ </Card>
+ </GlareHover>
+ )
+}
diff --git a/apps/www/registry/magicui/glare-hover.tsx b/apps/www/registry/magicui/glare-hover.tsx
new file mode 100644
index 00000000..a9e553a2
--- /dev/null
+++ b/apps/www/registry/magicui/glare-hover.tsx
@@ -0,0 +1,153 @@
+import type { ComponentProps, CSSProperties } from "react"
+import { useMemo } from "react"
+
+import { cn } from "@/lib/utils"
+
+export interface GlareHoverProps extends ComponentProps<"div"> {
+ /**
+ * Optional CSS width on the root element (e.g. `"100%"`, `"320px"`).
+ * @example
+ * ```tsx
+ * <GlareHover width="100%">...</GlareHover>
+ * ```
+ */
+ width?: string
+ /**
+ * Optional CSS height on the root element (e.g. `"auto"`, `"200px"`).
+ * @example
+ * ```tsx
+ * <GlareHover height="200px">...</GlareHover>
+ * ```
+ */
+ height?: string
+ /**
+ * Background color of the wrapper (CSS color string).
+ * @example
+ * ```tsx
+ * <GlareHover background="#0a0a0a">...</GlareHover>
+ * ```
+ */
+ background?: string
+ /**
+ * Glare highlight as `#rrggbb` or `#rgb`; parsed to `rgba` for the gradient.
+ * @example
+ * ```tsx
+ * <GlareHover color="#a78bfa">...</GlareHover>
+ * ```
+ */
+ color?: Color
+ /**
+ * Opacity applied to the glare color when converting hex to `rgba` (0–1).
+ * @example
+ * ```tsx
+ * <GlareHover color="#ffffff" opacity={0.35}>...</GlareHover>
+ * ```
+ */
+ opacity?: number
+ /**
+ * Gradient angle in degrees (`--gh-angle`).
+ * @example
+ * ```tsx
+ * <GlareHover angle={-30}>...</GlareHover>
+ * ```
+ */
+ angle?: number
+ /**
+ * Glare tile size as a percentage of the element (`--gh-size`, `background-size`).
+ * @example
+ * ```tsx
+ * <GlareHover size={280}>...</GlareHover>
+ * ```
+ */
+ size?: number
+ /**
+ * Transition duration for the glare sweep in milliseconds (`--gh-duration`).
+ * @example
+ * ```tsx
+ * <GlareHover duration={500}>...</GlareHover>
+ * ```
+ */
+ duration?: number
+ /**
+ * When `true`, the glare transition only runs on hover (no animation until pointer enters).
+ * @example
+ * ```tsx
+ * <GlareHover playOnce>...</GlareHover>
+ * ```
+ */
+ playOnce?: boolean
+}
+
+type Color = `#${string}`
+type RGBA = `rgba(${number},${number},${number},${number})`
+
+function parseHEX(color: Color, opacity: number): RGBA | Color {
+ const hex = color.replace("#", "")
+ const parse = (h: string) => Number.parseInt(h, 16)
+ if (/^[0-9A-Fa-f]{6}$/.test(hex)) {
+ return `rgba(${parse(hex.slice(0, 2))},${parse(hex.slice(2, 4))},${parse(hex.slice(4, 6))},${opacity})`
+ }
+ if (/^[0-9A-Fa-f]{3}$/.test(hex)) {
+ return `rgba(${parse(hex[0] + hex[0])},${parse(hex[1] + hex[1])},${parse(hex[2] + hex[2])},${opacity})`
+ }
+
+ return color
+}
+
+function GlareHover({
+ background = "#000",
+ children,
+ color = "#ffffff",
+ opacity = 0.5,
+ angle = -45,
+ size = 250,
+ duration = 650,
+ playOnce = false,
+ className,
+ style,
+ width,
+ height,
+ ...props
+}: GlareHoverProps) {
+ const rgba = useMemo(() => parseHEX(color, opacity), [color, opacity])
+
+ const cssVars = {
+ "--gh-angle": `${angle}deg`,
+ "--gh-duration": `${duration}ms`,
+ "--gh-size": `${size}%`,
+ "--gh-rgba": rgba,
+ background,
+ ...style,
+ ...(width !== undefined ? { width } : {}),
+ ...(height !== undefined ? { height } : {}),
+ } as CSSProperties
+
+ return (
+ <div
+ {...props}
+ className={cn(
+ "relative grid size-fit cursor-pointer place-items-center overflow-hidden bg-transparent",
+ // BEFORE ELEMENT
+ "before:pointer-events-none before:absolute before:inset-0 before:z-10 before:bg-no-repeat before:content-['']",
+ // GRADIENT
+ "before:[background-image:linear-gradient(var(--gh-angle),transparent_60%,var(--gh-rgba)_70%,transparent,transparent_100%)]",
+ // SIZE + POSITION
+ "before:[background-size:var(--gh-size)_var(--gh-size),100%_100%]",
+ "before:[background-position:-100%_-100%,0_0]",
+ // TRANSITION
+ !playOnce &&
+ "before:transition-[background-position] before:duration-[var(--gh-duration)] before:ease-in-out",
+ playOnce &&
+ "before:transition-none hover:before:transition-[background-position] hover:before:duration-[var(--gh-duration)]",
+ // HOVER EFFECT
+ "hover:before:[background-position:100%_100%,0_0]",
+ className
+ )}
+ style={cssVars}
+ >
+ {children}
+ </div>
+ )
+}
+
+export { GlareHover }
diff --git a/apps/www/registry/registry-examples.ts b/apps/www/registry/registry-examples.ts
index 18e91341..99098ffa 100644
--- a/apps/www/registry/registry-examples.ts
+++ b/apps/www/registry/registry-examples.ts
@@ -492,6 +492,45 @@ export const examples: Registry["items"] = [
},
],
},
+ {
+ name: "glare-hover-demo",
+ type: "registry:example",
+ title: "Glare Hover Demo",
+ description: "Pricing card with diagonal hover glare (duration 600ms).",
+ registryDependencies: ["@magicui/glare-hover"],
+ files: [
+ {
+ path: "example/glare-hover-demo.tsx",
+ type: "registry:example",
+ },
+ ],
+ },
+ {
+ name: "glare-hover-demo-cta",
+ type: "registry:example",
+ title: "Glare Hover Demo — CTA",
+ description: "CTA card with hover glare (700ms).",
+ registryDependencies: ["@magicui/glare-hover"],
+ files: [
+ {
+ path: "example/glare-hover-demo-cta.tsx",
+ type: "registry:example",
+ },
+ ],
+ },
+ {
+ name: "glare-hover-demo-alert",
+ type: "registry:example",
+ title: "Glare Hover Demo — Alerts",
+ description: "Three alerts with custom glare colors and opacity.",
+ registryDependencies: ["@magicui/glare-hover"],
+ files: [
+ {
+ path: "example/glare-hover-demo-alert.tsx",
+ type: "registry:example",
+ },
+ ],
+ },
{
name: "tweet-card-demo",
type: "registry:example",
diff --git a/apps/www/registry/registry-ui.ts b/apps/www/registry/registry-ui.ts
index 140129cd..03a44d7f 100644
--- a/apps/www/registry/registry-ui.ts
+++ b/apps/www/registry/registry-ui.ts
@@ -386,6 +386,19 @@ export const ui: Registry["items"] = [
},
],
},
+ {
+ name: "glare-hover",
+ type: "registry:ui",
+ title: "Glare Hover",
+ description:
+ "A diagonal glare on hover using a ::before gradient and CSS variables (angle, size, duration, color).",
+ files: [
+ {
+ path: "magicui/glare-hover.tsx",
+ type: "registry:ui",
+ },
+ ],
+ },
{
name: "shimmer-button",
type: "registry:ui",