# glow

A spotlight that follows the pointer over a grid of cards and lights up their borders, as on SaaS and developer tool sites.

A soft round light of radius follows the pointer with ease. Where it is near a card, the card’s border lights up in color along its rounded shape with a faint halo, and in the fill and both modes its surface glows too. The light crosses the gaps, so the neighboring cards catch its edge. It fades in as the pointer comes over the grid and out as it leaves. The cards stay as they are, the light draws over them.

Module `blocks`, category Blocks and cards. Import `@dioramajs/blocks/glow`. [Source](https://github.com/MasterKurosava/diorama/blob/main/packages/blocks/src/glow.ts)

A dark grid of six platform feature cards whose borders light up near the pointer.

```html title="index.html"
<div class="platform" data-dio="glow" data-dio-cards=".feature">
  <article class="feature">
    <h3>Edge functions</h3>
    <p>Run server code in 30 regions, a few milliseconds from every visitor.</p>
  </article>
  <article class="feature">
    <h3>Preview deploys</h3>
    <p>Every pull request gets its own URL to review before it ships.</p>
  </article>
  <article class="feature">
    <h3>Instant rollbacks</h3>
    <p>Point production back at any earlier build in one click.</p>
  </article>
  <article class="feature">
    <h3>Image CDN</h3>
    <p>Resized, compressed and cached on the first request.</p>
  </article>
  <article class="feature">
    <h3>Cron jobs</h3>
    <p>Schedule tasks with the syntax you already know.</p>
  </article>
  <article class="feature">
    <h3>Logs and traces</h3>
    <p>Search every request from the browser to the database.</p>
  </article>
</div>
```

## Usage

Put it on: a grid of cards with data-dio-cards naming the cards, or a single card; the cards can hold anything.

`start()` registers `glow`, so the attribute alone puts it on an element.

```html
<div class="features" data-dio="glow" data-dio-cards=".card"><article class="card"><h3>Edge functions</h3><p>Run code next to your users.</p></article><article class="card"><h3>Preview deploys</h3><p>Every branch gets its own URL.</p></article><article class="card"><h3>Analytics</h3><p>Real traffic, no cookies.</p></article></div>
```

In page transitions: The light fades with the page as it leaves.

## Params

| Name | Attribute | Type | Default | Description |
| --- | --- | --- | --- | --- |
| `mode` (rebuilds) | `data-dio-mode` | `'border' \| 'fill' \| 'both'` | `'border'` | border lights the outlines only, for cards with a hairline border; fill lights the surfaces only, for borderless tiles; both does both, the classic spotlight card. |
| `cards` (rebuilds) | `data-dio-cards` | `string` | `''` | Selector of the cards inside, like .card; empty makes the element the card. |
| `color` | `data-dio-color` | `color` | `'#ffffff'` | Color of the light, any CSS color. |
| `radius` | `data-dio-radius` | `number` 40 to 1000 px | `320` | Radius of the light around the pointer. |
| `border` | `data-dio-border` | `number` 0 to 6 px | `1` | Width of the lit border ring; 0 turns the ring off. |
| `fill` | `data-dio-fill` | `number` 0 to 0.6 | `0.12` | Strength of the surface glow in the fill and both modes; 0 turns it off. |
| `ease` | `data-dio-ease` | `number` 0 to 1 s | `0.1` | Time the light takes to catch up with the pointer; 0 sticks to it. |

Changing a param marked rebuilds re-runs the effect setup.

### Variants

- `mode`: `border`, `fill`, `both`
  - `border` lights the outlines only, for cards with a hairline border.
  - `fill` lights the surfaces only, for borderless tiles.
  - `both` does both, the classic spotlight card.

## Inputs and frames

Reads [`delta`](/docs/api/inputs#input-delta), [`opacity`](/docs/api/inputs#opacity), [`presence`](/docs/api/inputs#presence), [`reducedMotion`](/docs/api/inputs#input-reducedMotion). Draws only while something on it moves, then stops. Only while the pointer moves near the cards and while the light fades; none at rest. See [how a frame is decided](/docs/concepts/frames).

## Reduced motion and touch

With reduced motion it shows a still frame: motion inputs are zero and time stands still. Static: the light still sits under the pointer, but jumps with it and appears and goes at once, without trailing or fading.

Skipped on touch devices, which never load the engine for it. Off: phones and tablets have no pointer to follow, and the cards stay as they are.

```ts
import { start } from '@dioramajs/diorama'

start({ effects: { glow: { when: 'all', reducedMotion: 'off' } } })
```

## Cost and quality

Loads 2.1 KB the first time a page uses it. GPU: One instanced draw for up to 64 cards, only while the light is on. Memory: Two vec4 attributes per card, under 3 KB.

See [the quality plugin](/docs/effects/quality).

## Recipes

### Integration tiles without borders

Logo walls and integration lists often have no borders at all. The `fill` mode lights the surface of the tiles instead, and a cool `color` keeps it in the palette of a dark page.

Eight integration tiles on a dark page, the ones near the pointer glowing pale blue.

```html title="index.html"
<ul class="integrations" data-dio="glow" data-dio-cards="li" data-dio-mode="fill" data-dio-fill="0.16" data-dio-color="#9fb4ff">
  <li>GitHub</li>
  <li>GitLab</li>
  <li>Slack</li>
  <li>Linear</li>
  <li>Figma</li>
  <li>Sentry</li>
  <li>Stripe</li>
  <li>Postgres</li>
</ul>
```

### One card in the brand color

Put the effect on a single card when there is no grid, such as the featured plan of a pricing table. Without `cards` the element itself is the card, and the light starts within `radius` of it.

```html
<article
  class="plan"
  data-dio="glow"
  data-dio-mode="both"
  data-dio-color="#7c5cff"
  data-dio-radius="240"
>
  <h3>Pro</h3>
  <p>$24 per month, billed yearly.</p>
</article>
```

## Notes

The cards stay DOM: text, links and focus work as usual, and the light draws over them on the canvas. It reads each card’s `border-radius` per corner as the light comes on, so pill buttons and cards with mixed corners get a ring that fits. A site that draws the canvas behind the page with `start({ canvas: 'behind' })` needs cards with transparent backgrounds, or the cards hide the light.

Frames run only while the pointer moves near the cards and while the light fades in or out. A grid of up to 64 cards is one instanced draw.

On phones and tablets the effect is off, since there is no pointer to follow. Under reduced motion the light still sits under the pointer but jumps with it, without trailing or fading.

`mode` and `cards` rebuild the effect when they change; the other params change live.

## Related

- [beam](/docs/effects/beam.md): A light beam that runs around the rounded border of a feature card, an input field or a highlight box.
- [shine](/docs/effects/shine.md): A glint that sweeps across a button, a card or an image on hover, on a timer or as it comes into view.
- [beat](/docs/effects/beat.md): A cover, logo, card or play button that pulses with the music of a page player: it scales, shakes and glows, or sends out rings, on the beat.
- [coin](/docs/effects/coin.md): A coin, medal or token struck from a logo or a photo: it turns, catches the light and flips over.
- [dots](/docs/effects/dots.md): A dot grid behind a hero or in a card that answers the pointer: dots near it grow, move aside or glow, then settle back.
- [emboss](/docs/effects/emboss.md): Letters pressed into or raised out of paper, leather, brushed metal, stone or plaster, lit by a light that follows the pointer.
- [emoji](/docs/effects/emoji.md): Emoji or small pictures that float up from a like button, burst out of a success state or rain over a section.
- [keycaps](/docs/effects/keycaps.md): Each letter sits on a 3D mechanical keycap that presses down as if the word were typed, with a click under the pointer.
- [Reduced motion](/docs/guides/reduced-motion.md)
- [Performance and quality](/docs/guides/performance.md)
