本文へ移動
日本語
「プロダクトツアー」は Pro に含まれます。解除するとプレビューが表示されます。

仕組み

The spotlight is one element: its 9999px spread shadow dims the screen, and transform, width, height and radius animate together so it glides and resizes between targets on one curve. The card is placed below the target, else above, else at the bottom of the frame, clamped inside, with its arrow pointing at the target's centre. Positions are measured in layout pixels and remeasured when the frame resizes.

向いている場面

  • A first visit to a dense screen, pointing out three to five key places.
  • Introducing a new feature in an existing layout.

向かない場面

  • Explaining things the interface should make obvious: fix the interface instead.
  • Long tutorials: link to a guide.

使い方

import { useState } from 'react'
import { ProductTour } from './ProductTour.jsx'

export function Onboarding() {
  const [open, setOpen] = useState(true)
  return (
    <ProductTour
      open={open}
      onOpenChange={setOpen}
      steps={[
        { target: '[data-tour="new"]', title: 'Start a project', body: 'Create one per client or campaign.' },
        { target: '[data-tour="search"]', title: 'Find anything', body: 'Projects, files and people in one box.' },
      ]}
    />
  )
}

プロパティ

プロパティ型既定値説明
steps{ target: string | RefObject, title, body }[]—Steps in order. A string target is a CSS selector looked up inside the tour's parent element.
open / onOpenChangeboolean / (open) => voidopen trueShown or not; closes on Skip, Done, Escape or a click on the dimmed area.
step / defaultStep / onStepChangenumberdefaultStep 0The current step, controlled or not.
labelsobject—Replaces next, back, done, skip and progress (with {n} and {total}).
paddingnumber8Space between the target and the spotlight edge, in px.
containedbooleanfalseCover the parent element instead of the viewport.

アクセシビリティ

  • The card is a modal role dialog labelled by the step title and described by its text; the step count is a polite live region.
  • Moving to a step focuses the Next or Done button; Tab cycles inside the card; Left and Right change steps; Escape closes.
  • The spotlight and dimming are aria-hidden decoration; all meaning is in the card text.
  • Buttons are 32px high with visible focus rings.
  • With reduced motion the spotlight and card jump between targets and the pulse is off.

モーション

Spotlight and card 520ms cubic-bezier(0.65, 0, 0.25, 1); step text rises 4px in 360ms; two soft pulses around each new target; progress dot stretches to 18px.

プロジェクトに追加

Pro メンバーはプロンプトをコピーし、コーディングエージェントが無料コンポーネントと同じ手順でソースを導入します。

ProductTour.jsxproduct-tour.csstokens.cssREADME.md

2 つのファイルを一緒に導入します。スタイルは tokens.css の変数を読み、予備の値も持つため、単体でも表示できます。

オーバーレイ
「ボトムシート」は Pro に含まれます。解除するとプレビューが表示されます。