Glare Hover
magicui/glare-hoverFreeComponent
A diagonal glare on hover using a ::before gradient and CSS variables (angle, size, duration, color).
Live preview
live · rendered by the registry
Rendered by magicui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://magicui.design/r/glare-hover.jsonSource
1import type { ComponentProps, CSSProperties } from "react"2import { useMemo } from "react"34import { cn } from "@/lib/utils"56export interface GlareHoverProps extends ComponentProps<"div"> {7 /**8 * Optional CSS width on the root element (e.g. `"100%"`, `"320px"`).9 * @example10 * ```tsx11 * <GlareHover width="100%">...</GlareHover>12 * ```13 */14 width?: string15 /**16 * Optional CSS height on the root element (e.g. `"auto"`, `"200px"`).17 * @example18 * ```tsx19 * <GlareHover height="200px">...</GlareHover>20 * ```21 */22 height?: string23 /**24 * Background color of the wrapper (CSS color string).25 * @example26 * ```tsx27 * <GlareHover background="#0a0a0a">...</GlareHover>28 * ```29 */30 background?: string31 /**32 * Glare highlight as `#rrggbb` or `#rgb`; parsed to `rgba` for the gradient.33 * @example34 * ```tsx35 * <GlareHover color="#a78bfa">...</GlareHover>36 * ```37 */38 color?: Color39 /**40 * Opacity applied to the glare color when converting hex to `rgba` (0–1).41 * @example42 * ```tsx43 * <GlareHover color="#ffffff" opacity={0.35}>...</GlareHover>44 * ```45 */46 opacity?: number47 /**48 * Gradient angle in degrees (`--gh-angle`).49 * @example50 * ```tsx51 * <GlareHover angle={-30}>...</GlareHover>52 * ```53 */54 angle?: number55 /**56 * Glare tile size as a percentage of the element (`--gh-size`, `background-size`).57 * @example58 * ```tsx59 * <GlareHover size={280}>...</GlareHover>60 * ```61 */62 size?: number63 /**64 * Transition duration for the glare sweep in milliseconds (`--gh-duration`).65 * @example66 * ```tsx67 * <GlareHover duration={500}>...</GlareHover>68 * ```69 */70 duration?: number71 /**72 * When `true`, the glare transition only runs on hover (no animation until pointer enters).73 * @example74 * ```tsx75 * <GlareHover playOnce>...</GlareHover>76 * ```77 */78 playOnce?: boolean79}8081type Color = `#${string}`82type RGBA = `rgba(${number},${number},${number},${number})`8384function parseHEX(color: Color, opacity: number): RGBA | Color {85 const hex = color.replace("#", "")86 const parse = (h: string) => Number.parseInt(h, 16)87 if (/^[0-9A-Fa-f]{6}$/.test(hex)) {88 return `rgba(${parse(hex.slice(0, 2))},${parse(hex.slice(2, 4))},${parse(hex.slice(4, 6))},${opacity})`89 }90 if (/^[0-9A-Fa-f]{3}$/.test(hex)) {91 return `rgba(${parse(hex[0] + hex[0])},${parse(hex[1] + hex[1])},${parse(hex[2] + hex[2])},${opacity})`92 }9394 return color95}9697function GlareHover({98// … truncated
Files it writes
More from magicui
All 247 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Androidandroid | magicui | Components | Free | no deps | |
| Animated Beamanimated-beam | magicui | Components | Free | 1 dep | |
| Animated Circular Progress Baranimated-circular-progress-bar | magicui | Components | Free | no deps | |
| Animated Gradient Textanimated-gradient-text | magicui | Components | Free | no deps | |
| Animated Grid Patternanimated-grid-pattern | magicui | Components | Free | 1 dep | |
| Animated Listanimated-list | magicui | Components | Free | 1 dep | |
| Animated Shiny Textanimated-shiny-text | magicui | Components | Free | no deps | |
| Theme Toggleranimated-theme-toggler | magicui | Components | Free | 1 dep |
