Diorama

Made for a big screen.

This site is one 3D scene, built for a computer: a wide window and a mouse. Open dioramajs.dev on a desktop or a laptop to see it.This site is one 3D scene, built for a wide window. Make this one wider, or open dioramajs.dev on a larger screen.

GitHub

DioramaDocs

glow

Blocks and cards

@dioramajs/blocks/glowSource

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

View as Markdown
On this page

Edge functions

Run server code in 30 regions, a few milliseconds from every visitor.

Preview deploys

Every pull request gets its own URL to review before it ships.

Instant rollbacks

Point production back at any earlier build in one click.

Image CDN

Resized, compressed and cached on the first request.

Cron jobs

Schedule tasks with the syntax you already know.

Logs and traces

Search every request from the browser to the database.

Live preview needs WebGPU or WebGL 2. A dark grid of six platform feature cards whose borders light up near the pointer.

This example failed to draw.

Move the pointer over the cards and across the gaps between them. Switch the mode, or move the sliders.
Params of glow
mode

border lights the outlines only, for cards with a hairline border.

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. The tabs below are the example above, with the values you set.

To change its code, copy the source into your effects folder; the copy replaces the built-in.

Terminal window
npx @dioramajs/diorama add glow
<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>
import { start } from '@dioramajs/diorama'
const app = start()
app.attach('.platform', 'glow', {
mode: 'border',
radius: 320,
border: 1,
fill: 0.12,
ease: 0.1,
})
import { start } from '@dioramajs/diorama'
import glow from '@dioramajs/blocks/glow'
const app = start()
app.attach('.platform', glow({
mode: 'border',
radius: 320,
border: 1,
fill: 0.12,
ease: 0.1,
}))

Page transitions

The light fades with the page as it leaves. How a flight flies.

Params

Every param is also an attribute, and both app.attach() and the handle take it by name.

ParamTypeDefaultDescription
moderebuildsdata-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.
cardsrebuildsdata-dio-cardsstring''Selector of the cards inside, like .card; empty makes the element the card.
colordata-dio-colorcolor'#ffffff'Color of the light, any CSS color.
radiusdata-dio-radiusnumber40 to 1000 px320Radius of the light around the pointer.
borderdata-dio-bordernumber0 to 6 px1Width of the lit border ring; 0 turns the ring off.
filldata-dio-fillnumber0 to 0.60.12Strength of the surface glow in the fill and both modes; 0 turns it off.
easedata-dio-easenumber0 to 1 s0.1Time the light takes to catch up with the pointer; 0 sticks to it.

Params marked rebuilds re-run the effect's setup when they change, so set them before the element shows.

Inputs and frames

It reads delta, opacity, presence and 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. How a frame is decided.

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.

To run it on touch devices too, or to change what reduced motion does, patch it in start().

import { start } from '@dioramajs/diorama'
start({ effects: { glow: { when: 'all', reducedMotion: 'off' } } })

Cost and quality

Download
2.1 KB min+gzip 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.
Frames
Idle at rest

It runs from the low tier up. Every tier draws it the same way. The quality plugin picks the tier for each device.

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.

  • GitHub
  • GitLab
  • Slack
  • Linear
  • Figma
  • Sentry
  • Stripe
  • Postgres

Live preview needs WebGPU or WebGL 2. Eight integration tiles on a dark page, the ones near the pointer glowing pale blue.

This example failed to draw.

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

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