StealThis .dev

Tour Spotlight

Product tour component — highlights UI elements with a spotlight overlay, shows tooltip with prev/next navigation.

Open in Lab
vanilla-js css
Targets: JS HTML

Code

Tour Spotlight

A product tour component that guides users through a UI by highlighting elements with a spotlight overlay and showing a contextual tooltip. Supports previous/next navigation, step indicators, and smooth transitions between targets.

How it works

  1. A full-screen SVG overlay with a clip-path cutout creates the spotlight effect
  2. The cutout is calculated from the target element’s getBoundingClientRect() with a configurable padding
  3. A tooltip panel is absolutely positioned adjacent to the highlighted element
  4. Transitions animate both the clip-path rect and the tooltip position using CSS transitions
  5. Scroll-into-view ensures the target is visible before positioning

Features

  • Smooth SVG clip-path animation between steps
  • Tooltip auto-positions (top/bottom/left/right) based on available viewport space
  • Step counter with progress dots
  • Skip button to dismiss the tour at any time
  • Escape key closes the tour
  • Accessible: aria-live announcements, focus management

Demo

A 4-step tour on a mock dashboard:

  1. Header navigation bar
  2. Stats cards row
  3. Chart area
  4. Action button

When to use it

  • First-run onboarding flows
  • Feature introduction after a release
  • Complex UI walkthroughs