Atlassian Design System JS behaviour

Spotlight

A modal veil that dims everything but the teaching target — image, copy and Skip/Next actions for classic product onboarding tours.

Documentation

Real scenarios

The component as it is used in a product — not a specimen grid.

The tour that dims the world

Three stops, one moving hole — the dialog measures its target and sits above or below it; Skip and Escape let people out at any step.

Runs against the board below — the veil never leaves this frame.

Sprint 24 board

To do
NABU-247Search tokens
NABU-253Dark audit
In progress
NABU-241Payment webhook
Done
NABU-238Seed script

Four placements, one rule

The dialog always claims the side with more room — bottom, top, left or right — and the veil keeps the rest of the page at 77% ink.

placement · bottom
placement · top
placement · start
placement · end

Important props

Important props
Prop Type Default What it does
target element null The element that stays lit; the rest is veiled at 77% black.
placement string 'bottom' The dialog sits beside the target: top, bottom, left, right.
actions slot null The Skip and Next row; the last step’s Next becomes Finish.
pulse boolean true A pulsing ring around the target until the tour is finished.

Snippet

<div class="atsp" x-data="{ step: 0 }">
    <button class="atsp-target" data-lit>Create</button>
    <div class="atsp-dialog">
        <img src="…" alt="">
        <h4>Create your first issue here</h4>
        <p>The Create button is where every new piece of work starts.</p>
        <footer>
            <button>Skip</button>
            <button data-primary>Next</button>
        </footer>
    </div>
</div>

<style>
.atsp { position: relative; overflow: clip; }
.atsp-target[data-lit] { position: relative; z-index: 2; border-radius: 3px;
                         box-shadow: 0 0 0 200vmax rgba(9, 30, 66, .77); }
.atsp-dialog { position: absolute; z-index: 3; inline-size: 264px; padding: 16px;
               border-radius: 4px; background: #FFFFFF; }
.atsp-dialog h4 { margin: 0 0 4px; font: 600 14px Inter, system-ui; color: #172B4D; }
.atsp-dialog footer { display: flex; justify-content: flex-end; gap: 8px; }
</style>
// app/Pages/Tour.jsx — Inertia page; renders the React snippet
// below unchanged, with Inertia's Link wired into the provider.
import { Link } from '@inertiajs/react';
import { NabuXUIProvider } from '@nabuxai/ui-react';
import OnboardingTour from '@/components/OnboardingTour';

export default function Tour() {
  return (
    <NabuXUIProvider locale="en" linkComponent={Link}>
      <main className="nx-page">
        <OnboardingTour />
      </main>
    </NabuXUIProvider>
  );
}
// OnboardingTour.jsx — the spotlight: one lit target, everything else dimmed
import { useLayoutEffect, useRef, useState } from 'react';
import '@nabuxai/ui-core/css';

const STEPS = [
  { title: 'Create', body: 'Every piece of work starts here — the issue form opens pre-filled.' },
  { title: 'Watch', body: 'Watching this board pages every change straight to you.' },
];

export default function OnboardingTour() {
  const [step, setStep] = useState(-1); // -1 = the tour is off
  const stageRef = useRef(null);
  const targetRef = useRef(null);
  const [hole, setHole] = useState({ x: 0, y: 0, w: 0, h: 0 });

  // Measure the target so the veil's hole and the dialog track it.
  useLayoutEffect(() => {
    if (step < 0) return;
    const stage = stageRef.current?.getBoundingClientRect();
    const target = targetRef.current?.getBoundingClientRect();
    if (!stage || !target) return;
    const pad = 6;
    setHole({
      x: target.left - stage.left - pad, y: target.top - stage.top - pad,
      w: target.width + pad * 2, h: target.height + pad * 2,
    });
  }, [step]);

  const on = step >= 0;

  return (
    <>
      <style>{`
        .atsp-stage { position: relative; isolation: isolate; overflow: clip; max-inline-size: 26rem;
                      padding: .9rem; border: 1px solid #DFE1E6; border-radius: 6px; background: #F7F8F9;
                      display: grid; gap: .75rem; justify-items: start;
                      font-family: Inter, system-ui, sans-serif; }
        .atsp-create { block-size: 1.9rem; padding-inline: .8rem; border: none; border-radius: 3px;
                       cursor: pointer; background: #0C66E4; color: #fff;
                       font: 500 .78rem/1 Inter, system-ui; }
        .atsp-board { display: grid; gap: .6rem; grid-template-columns: repeat(3, 1fr); inline-size: 100%; }
        .atsp-card { border: 1px solid #DFE1E6; border-radius: 3px; padding: .45rem .5rem; background: #fff;
                     font: 400 .72rem/1.4 Inter, system-ui; color: #172B4D; }
        /* The moving hole: a transparent rect over a 200vmax scrim. */
        .atsp-veil { position: absolute; z-index: 2; border-radius: 6px; pointer-events: none;
                     box-shadow: 0 0 0 4px rgba(12, 102, 228, .4), 0 0 0 200vmax rgba(9, 30, 66, .77);
                     transition: all .35s cubic-bezier(.2, 0, 0, 1); }
        .atsp-pop { position: absolute; z-index: 3; inline-size: 15rem; padding: .9rem; border-radius: 4px;
                    background: #fff; box-shadow: 0 8px 12px rgba(9, 30, 66, .16); }
        .atsp-pop h5 { margin: 0 0 .2rem; font: 600 .86rem/1.4 Inter, system-ui; color: #172B4D; }
        .atsp-pop p { margin: 0 0 .7rem; font: 400 .76rem/1.6 Inter, system-ui; color: #44546F; }
        .atsp-foot { display: flex; align-items: center; gap: .5rem; }
        .atsp-skip { margin-inline-start: auto; border: none; background: none; cursor: pointer;
                     font: 500 .76rem Inter, system-ui; color: #626F86; }
        .atsp-next { border: none; border-radius: 3px; block-size: 1.85rem; padding-inline: .8rem;
                     cursor: pointer; background: #0C66E4; color: #fff;
                     font: 500 .76rem/1 Inter, system-ui; }
      `}</style>
      <div className="atsp-stage" ref={stageRef}>
        <button type="button" className="atsp-create" ref={targetRef}>Create</button>
        <div className="atsp-board" aria-hidden="true">
          <div className="atsp-card">NABU-241 · Webhook retries</div>
          <div className="atsp-card">NABU-247 · Search tokens</div>
          <div className="atsp-card">NABU-253 · Istanbul checklist</div>
        </div>
        {on && (
          <>
            <div className="atsp-veil" style={{
              insetBlockStart: hole.y, insetInlineStart: hole.x, inlineSize: hole.w, blockSize: hole.h,
            }} />
            <div className="atsp-pop" style={{ insetBlockStart: hole.y + hole.h + 8, insetInlineStart: hole.x }}>
              <h5>{STEPS[step].title}</h5>
              <p>{STEPS[step].body}</p>
              <div className="atsp-foot">
                <button type="button" className="atsp-skip" onClick={() => setStep(-1)}>Skip</button>
                {/* The last step's Next becomes Finish. */}
                <button type="button" className="atsp-next"
                  onClick={() => setStep(step < STEPS.length - 1 ? step + 1 : -1)}>
                  {step < STEPS.length - 1 ? 'Next' : 'Finish'}
                </button>
              </div>
            </div>
          </>
        )}
        {!on && (
          <button type="button" className="atsp-create" onClick={() => setStep(0)}>Start the tour</button>
        )}
      </div>
    </>
  );
}
<!-- OnboardingTour.vue — the spotlight: one lit target, everything else dimmed -->
<script setup lang="ts">
import { nextTick, ref } from 'vue';
import '@nabuxai/ui-core/css';

const steps = [
  { title: 'Create', body: 'Every piece of work starts here — the issue form opens pre-filled.' },
  { title: 'Watch', body: 'Watching this board pages every change straight to you.' },
];
const step = ref(-1); // -1 = the tour is off
const stage = ref<HTMLElement | null>(null);
const target = ref<HTMLElement | null>(null);
const hole = ref({ x: 0, y: 0, w: 0, h: 0 });

// Measure the target so the veil's hole and the dialog track it.
async function place() {
  if (step.value < 0) return;
  await nextTick();
  const sr = stage.value?.getBoundingClientRect();
  const tr = target.value?.getBoundingClientRect();
  if (!sr || !tr) return;
  const pad = 6;
  hole.value = {
    x: tr.left - sr.left - pad, y: tr.top - sr.top - pad,
    w: tr.width + pad * 2, h: tr.height + pad * 2,
  };
}
function go(next: number) { step.value = next; place(); }
</script>

<template>
  <div ref="stage" class="atsp-stage">
    <button ref="target" type="button" class="atsp-create">Create</button>
    <div class="atsp-board" aria-hidden="true">
      <div class="atsp-card">NABU-241 · Webhook retries</div>
      <div class="atsp-card">NABU-247 · Search tokens</div>
      <div class="atsp-card">NABU-253 · Istanbul checklist</div>
    </div>
    <template v-if="step >= 0">
      <!-- The moving hole: a transparent rect over a 200vmax scrim. -->
      <div class="atsp-veil" :style="{
        insetBlockStart: hole.x ? hole.y + 'px' : '0',
        insetInlineStart: hole.x + 'px', inlineSize: hole.w + 'px', blockSize: hole.h + 'px',
      }" />
      <div class="atsp-pop" :style="{ insetBlockStart: hole.y + hole.h + 8 + 'px', insetInlineStart: hole.x + 'px' }">
        <h5>{{ steps[step].title }}</h5>
        <p>{{ steps[step].body }}</p>
        <div class="atsp-foot">
          <button type="button" class="atsp-skip" @click="go(-1)">Skip</button>
          <!-- The last step's Next becomes Finish. -->
          <button type="button" class="atsp-next" @click="go(step < steps.length - 1 ? step + 1 : -1)">
            {{ step < steps.length - 1 ? 'Next' : 'Finish' }}
          </button>
        </div>
      </div>
    </template>
    <button v-if="step < 0" type="button" class="atsp-create" @click="go(0)">Start the tour</button>
  </div>
</template>

<style scoped>
.atsp-stage { position: relative; isolation: isolate; overflow: clip; max-inline-size: 26rem;
              padding: .9rem; border: 1px solid #DFE1E6; border-radius: 6px; background: #F7F8F9;
              display: grid; gap: .75rem; justify-items: start;
              font-family: Inter, system-ui, sans-serif; }
.atsp-create { block-size: 1.9rem; padding-inline: .8rem; border: none; border-radius: 3px;
               cursor: pointer; background: #0C66E4; color: #fff;
               font: 500 .78rem/1 Inter, system-ui; }
.atsp-board { display: grid; gap: .6rem; grid-template-columns: repeat(3, 1fr); inline-size: 100%; }
.atsp-card { border: 1px solid #DFE1E6; border-radius: 3px; padding: .45rem .5rem; background: #fff;
             font: 400 .72rem/1.4 Inter, system-ui; color: #172B4D; }
.atsp-veil { position: absolute; inset-block-start: 0; inset-inline-start: 0; z-index: 2; border-radius: 6px;
             pointer-events: none;
             box-shadow: 0 0 0 4px rgba(12, 102, 228, .4), 0 0 0 200vmax rgba(9, 30, 66, .77);
             transition: all .35s cubic-bezier(.2, 0, 0, 1); }
.atsp-pop { position: absolute; z-index: 3; inline-size: 15rem; padding: .9rem; border-radius: 4px;
            background: #fff; box-shadow: 0 8px 12px rgba(9, 30, 66, .16); }
.atsp-pop h5 { margin: 0 0 .2rem; font: 600 .86rem/1.4 Inter, system-ui; color: #172B4D; }
.atsp-pop p { margin: 0 0 .7rem; font: 400 .76rem/1.6 Inter, system-ui; color: #44546F; }
.atsp-foot { display: flex; align-items: center; gap: .5rem; }
.atsp-skip { margin-inline-start: auto; border: none; background: none; cursor: pointer;
             font: 500 .76rem Inter, system-ui; color: #626F86; }
.atsp-next { border: none; border-radius: 3px; block-size: 1.85rem; padding-inline: .8rem;
             cursor: pointer; background: #0C66E4; color: #fff;
             font: 500 .76rem/1 Inter, system-ui; }
</style>
<!-- OnboardingTour.svelte — the spotlight: one lit target, everything else dimmed -->
<script lang="ts">
  import { onMount } from 'svelte';
  import '@nabuxai/ui-core/css';

  const steps = [
    { title: 'Create', body: 'Every piece of work starts here — the issue form opens pre-filled.' },
    { title: 'Watch', body: 'Watching this board pages every change straight to you.' },
  ];
  let step = $state(-1); // -1 = the tour is off
  let stage: HTMLElement;
  let target: HTMLButtonElement;
  let hole = $state({ x: 0, y: 0, w: 0, h: 0 });

  // Measure the target so the veil's hole and the dialog track it.
  function place() {
    if (step < 0) return;
    const sr = stage.getBoundingClientRect();
    const tr = target.getBoundingClientRect();
    const pad = 6;
    hole = {
      x: tr.left - sr.left - pad, y: tr.top - sr.top - pad,
      w: tr.width + pad * 2, h: tr.height + pad * 2,
    };
  }
  function go(next: number) { step = next; place(); }
</script>

<div bind:this={stage} class="atsp-stage">
  <button bind:this={target} type="button" class="atsp-create">Create</button>
  <div class="atsp-board" aria-hidden="true">
    <div class="atsp-card">NABU-241 · Webhook retries</div>
    <div class="atsp-card">NABU-247 · Search tokens</div>
    <div class="atsp-card">NABU-253 · Istanbul checklist</div>
  </div>
  {#if step >= 0}
    <!-- The moving hole: a transparent rect over a 200vmax scrim. -->
    <div
      class="atsp-veil"
      style:inset-block-start="{hole.y}px"
      style:inset-inline-start="{hole.x}px"
      style:inline-size="{hole.w}px"
      style:block-size="{hole.h}px"
    ></div>
    <div class="atsp-pop" style:inset-block-start="{hole.y + hole.h + 8}px" style:inset-inline-start="{hole.x}px">
      <h5>{steps[step].title}</h5>
      <p>{steps[step].body}</p>
      <div class="atsp-foot">
        <button type="button" class="atsp-skip" onclick={() => go(-1)}>Skip</button>
        <!-- The last step's Next becomes Finish. -->
        <button type="button" class="atsp-next" onclick={() => go(step < steps.length - 1 ? step + 1 : -1)}>
          {step < steps.length - 1 ? 'Next' : 'Finish'}
        </button>
      </div>
    </div>
  {:else}
    <button type="button" class="atsp-create" onclick={() => go(0)}>Start the tour</button>
  {/if}
</div>

<style>
.atsp-stage { position: relative; isolation: isolate; overflow: clip; max-inline-size: 26rem;
              padding: .9rem; border: 1px solid #DFE1E6; border-radius: 6px; background: #F7F8F9;
              display: grid; gap: .75rem; justify-items: start;
              font-family: Inter, system-ui, sans-serif; }
.atsp-create { block-size: 1.9rem; padding-inline: .8rem; border: none; border-radius: 3px;
               cursor: pointer; background: #0C66E4; color: #fff;
               font: 500 .78rem/1 Inter, system-ui; }
.atsp-board { display: grid; gap: .6rem; grid-template-columns: repeat(3, 1fr); inline-size: 100%; }
.atsp-card { border: 1px solid #DFE1E6; border-radius: 3px; padding: .45rem .5rem; background: #fff;
             font: 400 .72rem/1.4 Inter, system-ui; color: #172B4D; }
.atsp-veil { position: absolute; inset-block-start: 0; inset-inline-start: 0; z-index: 2; border-radius: 6px;
             pointer-events: none;
             box-shadow: 0 0 0 4px rgba(12, 102, 228, .4), 0 0 0 200vmax rgba(9, 30, 66, .77);
             transition: all .35s cubic-bezier(.2, 0, 0, 1); }
.atsp-pop { position: absolute; z-index: 3; inline-size: 15rem; padding: .9rem; border-radius: 4px;
            background: #fff; box-shadow: 0 8px 12px rgba(9, 30, 66, .16); }
.atsp-pop h5 { margin: 0 0 .2rem; font: 600 .86rem/1.4 Inter, system-ui; color: #172B4D; }
.atsp-pop p { margin: 0 0 .7rem; font: 400 .76rem/1.6 Inter, system-ui; color: #44546F; }
.atsp-foot { display: flex; align-items: center; gap: .5rem; }
.atsp-skip { margin-inline-start: auto; border: none; background: none; cursor: pointer;
             font: 500 .76rem Inter, system-ui; color: #626F86; }
.atsp-next { border: none; border-radius: 3px; block-size: 1.85rem; padding-inline: .8rem;
             cursor: pointer; background: #0C66E4; color: #fff;
             font: 500 .76rem/1 Inter, system-ui; }
</style>