Skip to content

Spotlight & Popover

GuideFlow's spotlight overlay draws an animated SVG cutout around the target element, directing user attention. The popover anchors to the target with smart positioning.

Spotlight Configuration

Configure the spotlight globally when creating the instance:

ts
const gf = createGuideFlow({
  spotlight: {
    padding: 8,          // px around the highlighted element
    borderRadius: 4,     // corner radius of the cutout
    animated: true,       // smooth transitions between targets
    overlayColor: '#000', // overlay background color
    overlayOpacity: 0.5,  // overlay opacity (0–1)
  },
})

Options

OptionTypeDefaultDescription
paddingnumber8Padding around highlighted element (px)
borderRadiusnumber4Corner radius of spotlight cutout (px)
animatedbooleantrueAnimate spotlight transitions
overlayColorstring'#000'Overlay background color
overlayOpacitynumber0.5Overlay opacity (0–1)

Click-Through

By default, the overlay blocks clicks outside the spotlight. Enable click-through per step:

ts
{
  id: 'interactive-step',
  content: { title: 'Try clicking the button' },
  target: '#action-btn',
  clickThrough: true, // user can interact with the highlighted element
}

Popover Placements

The popover automatically positions itself relative to the target. Available placements:

PlacementDescription
topCentered above
top-startAbove, aligned left
top-endAbove, aligned right
bottomCentered below
bottom-startBelow, aligned left
bottom-endBelow, aligned right
leftCentered to the left
left-startLeft, aligned top
left-endLeft, aligned bottom
rightCentered to the right
right-startRight, aligned top
right-endRight, aligned bottom
centerCentered on screen (no target)

Auto-Scroll

By default, GuideFlow scrolls the target element into view. Disable per step:

ts
{
  id: 'no-scroll',
  content: { title: 'Already visible' },
  target: '#visible-element',
  scrollIntoView: false,
}

CSP Compliance

GuideFlow injects styles for the spotlight overlay. For Content Security Policy compliance, pass a nonce:

ts
const gf = createGuideFlow({
  nonce: 'abc123',  // added to all injected <style> tags
})

Custom Renderer

Replace the default popover with your own renderer:

ts
const gf = createGuideFlow({
  renderer: {
    render(step, actions) {
      // Return your custom DOM element
      const el = document.createElement('div')
      el.innerHTML = `<h3>${step.content.title}</h3>`
      return el
    },
    destroy() {
      // Clean up
    },
  },
})

Released under the MIT License.