Skip to content

Spotlight ​

A dim layer with a hole punched in it: one region of the page stays at full brightness while everything else recedes. Pair it with Tour (via its spotlight prop) or drive it directly with any rectangle you already have.

Basic Usage ​

PreviewCode
RTL
html
<div style="padding:2rem;">
  <ore-button id="target" color="primary">Click me to toggle the dim</ore-button>
</div>
<ore-spotlight id="spot"></ore-spotlight>

<script type="module">
  import '@vielzeug/refine/button';
  import '@vielzeug/refine/spotlight';

  const spot = document.getElementById('spot');
  const target = document.getElementById('target');

  // The dim never captures pointer events, so the button inside the cutout
  // stays clickable: clicking it toggles the spotlight.
  spot.rect = target.getBoundingClientRect();
  target.addEventListener('click', () => {
    spot.visible = !spot.visible;
  });
</script>

How It Works ​

The dim is a single oversized box-shadow on the cutout element, so the hole animates with the element's own geometry: when a tour moves to the next step, the highlight slides to the new target instead of blinking out and back.

The layer never captures pointer events: a beacon shows the way, it does not block the road. The element inside the cutout stays clickable. The overlay is decorative by definition and carries aria-hidden; whatever dialog or popover owns the moment handles interaction and announcement.

Omit rect (or pass a zero-size one) to dim the whole page without a cutout.

API Reference ​

Attributes ​

AttributeTypeDefaultDescription
radiusnumber8Cutout corner radius in px
visiblebooleantrueShow the dim layer

The rect prop is JS-only (no attribute): assign a DOMRect or a plain { x, y, width, height } in viewport pixels.

ts
spotlight.rect = element.getBoundingClientRect();
spotlight.rect = null; // dim the whole page

CSS Custom Properties ​

PropertyDescription
--spotlight-dimDim color (default --color-scrim)
--spotlight-ringRing drawn around the cutout (default: none)
--spotlight-radiusCutout corner radius
--spotlight-transitionGeometry transition (default: 240ms spring)

Parts ​

PartDescription
overlayThe fixed dim layer
cutoutThe highlighted rectangle

Accessibility ​

The overlay is purely decorative and always aria-hidden. It never intercepts pointer events, so page content outside the cutout stays interactive: use a dialog or popover presentation when you want to block interaction.

  • Tour: product-tour step card with a built-in spotlight option
  • Dialog: modal presentation with focus trap and background lock