# Glare Hover

- Page: https://jiguang132.com/resources/magic-ui/docs/glare-hover
- Resource: Magic UI (https://jiguang132.com/resources/magic-ui.md)
- All guides: https://jiguang132.com/resources/magic-ui/docs.md

Install: `npx shadcn@latest add https://jiguang132.com/r/magic-ui/glare-hover.json`

## Use case

Sweep a highlight across content on hover.

## Native props used by the examples

Extracted from all local examples for this entry, grouped by imported module and native owner, including other Magic components used by compound demos. This is not an exhaustive API or a universal host variant. Inspect spread object declarations and the source types/defaults below.

| Owning component prop | Explanation | Example source |
| --- | --- | --- |
| `GlareHover.className` (glare-hover) | Classes on this native component; initialize Tailwind and its required CSS first. | `examples/glare-hover-demo.tsx`、`examples/glare-hover-demo-cta.tsx`、`examples/glare-hover-demo-alert.tsx` |
| `GlareHover.duration` (glare-hover) | Glare sweep duration in milliseconds. | `examples/glare-hover-demo.tsx`、`examples/glare-hover-demo-cta.tsx`、`examples/glare-hover-demo-alert.tsx` |
| `GlareHover.children` (glare-hover) | Native child content; keep the owning component's text/element constraints. | `examples/glare-hover-demo.tsx`、`examples/glare-hover-demo-cta.tsx`、`examples/glare-hover-demo-alert.tsx` |
| `GlareHover.color` (glare-hover) | The owning effect's native color; preserve any restricted color format. | `examples/glare-hover-demo-cta.tsx`、`examples/glare-hover-demo-alert.tsx` |
| `GlareHover.opacity` (glare-hover) | Native effect opacity; normally a 0–1 fraction. | `examples/glare-hover-demo-alert.tsx` |

## Interaction and state checks

- Glare Hover Demo — `glare-hover-demo`
- Glare Hover Demo — CTA — `glare-hover-demo-cta`
- Glare Hover Demo — Alerts — `glare-hover-demo-alert`

These names identify real example entries, not new component props or extra components. Check pointer/keyboard behavior, themes, small screens and failures for the selected example. Decorative effects must not invent disabled/error/submission states. Complete example installation includes the actual dependency closure.

## Business integration boundary

duration is milliseconds here, unlike many Motion-based components. color must be a hex color accepted by the native parser.

## Host and motion setup

Initialize Tailwind CSS v4, semantic CSS variables and the dark variant; import the independent local Registry namespace. Reuse an existing next-themes Provider without substituting JGuang UI/Base UI/HeroUI APIs. Mount effects in view and unmount offscreen; provide static alternatives for unavailable Canvas/WebGL or failed remote media. Respect prefers-reduced-motion and verify timer/RAF/observer/listener cleanup: stopping CSS alone does not prove the engine stopped. Examples provide no backend, login, payment or real AI stream. This practical guide is bilingual; detailed upstream references and demo text retain their original language.


## Available examples

glare-hover-demo, glare-hover-demo-cta, glare-hover-demo-alert

Demo state and mock data do not provide a backend service. Inspect the component props before wiring real data.




## Examples

### CTA



### Alerts



## 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>



<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.

## Credits

- Credit to [@chishiyac](https://github.com/chishiyac)




## Complete example installation

The component command installs the component. Each example command also includes its actual imported components, native support UI, utilities and pinned dependencies. Helpers are not additional catalog components.

### Glare Hover Demo

```bash
npx shadcn@latest add https://jiguang132.com/r/magic-ui/examples/glare-hover/glare-hover-demo.json
```

Default import: `@/components/magicui/examples/glare-hover-demo`

Dependencies: `@radix-ui/react-slot@1.3.0`, `class-variance-authority@0.7.1`, `clsx@2.1.1`, `tailwind-merge@3.6.0`

### Glare Hover Demo — CTA

```bash
npx shadcn@latest add https://jiguang132.com/r/magic-ui/examples/glare-hover/glare-hover-demo-cta.json
```

Default import: `@/components/magicui/examples/glare-hover-demo-cta`

Dependencies: `@radix-ui/react-slot@1.3.0`, `class-variance-authority@0.7.1`, `clsx@2.1.1`, `tailwind-merge@3.6.0`

### Glare Hover Demo — Alerts

```bash
npx shadcn@latest add https://jiguang132.com/r/magic-ui/examples/glare-hover/glare-hover-demo-alert.json
```

Default import: `@/components/magicui/examples/glare-hover-demo-alert`

Dependencies: `class-variance-authority@0.7.1`, `clsx@2.1.1`, `lucide-react@1.24.0`, `tailwind-merge@3.6.0`

### Minimal usage and theme

```tsx
import Demo from '@/components/magicui/examples/glare-hover-demo';
import { ThemeProvider } from 'next-themes';
export default function Example() {
  return <ThemeProvider attribute="class" defaultTheme="system" enableSystem><Demo /></ThemeProvider>;
}

```

Initialize Tailwind CSS v4, semantic color variables and the dark variant first. Reuse an existing next-themes provider rather than nesting another. Next Link examples require a Next.js environment; in static Vite projects adapt the demo links to your router without changing the native component API. Some media and tweets require network access. Examples do not supply authentication or backend services.


## Source-backed parameter reference

Implementation signatures and types are generated from the pinned local source. Optional props, native inherited types, union branches and never exclusions are preserved. A forwardRef implementation's ref is a React reference, not an additional business prop.


```ts
GlareHover({
  background = "#000",
  children,
  color = "#ffffff",
  opacity = 0.5,
  angle = -45,
  size = 250,
  duration = 650,
  playOnce = false,
  className,
  style,
  width,
  height,
  ...props
}: GlareHoverProps)
```



````ts
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}`
````


### Destructuring defaults in source

Only defaults written directly in parameter/props destructuring are listed. Conditional expressions, runtime theme and computed values require source inspection; this is not an exhaustive behavior-default list.


```ts
// GlareHover
background = "#000"

// GlareHover
color = "#ffffff"

// GlareHover
opacity = 0.5

// GlareHover
angle = -45

// GlareHover
size = 250

// GlareHover
duration = 650

// GlareHover
playOnce = false
```


### Native and external types

External types remain defined by React or native dependencies, not manually expanded into guessed props. The installed version's TypeScript definitions are authoritative.


```ts
ComponentProps<"div">
```

---

Index of all JGuang resources: https://jiguang132.com/llms.txt
