Start here
Getting started
Install Docent, describe a tour, and show it to someone. About five minutes from nothing to a working tour.
A tour walks someone through your interface one element at a time. Each step dims the page, spotlights one element, and explains it in a small popover with Back and Next buttons. Docent handles the positioning, scrolling, keyboard and focus. You write the words and decide which element each step points at.
-
Install the package for your stack.
Terminal window pnpm add @docentjs/domTerminal window pnpm add @docentjs/reactTerminal window pnpm add @docentjs/vueTerminal window pnpm add @docentjs/svelteOne package is enough. The framework packages include the web renderer and the engine, and re-export everything you need, so in a React app every import comes from
@docentjs/react. -
Describe the tour.
A tour is a plain object: an
idand a list ofsteps.defineTouradds type checking and stamps the schema version.tours.ts import { defineTour } from '@docentjs/dom'export const welcome = defineTour({id: 'welcome',options: { showProgress: true },steps: [{ id: 'intro', title: 'Welcome', body: 'This takes about a minute.' },{ id: 'sidebar', target: { name: 'sidebar' }, title: 'Navigation', placement: 'right' },{ id: 'new', target: '#new-project', title: 'Create a project', advance: { on: 'click' } },{ id: 'done', title: 'All set' },],})A step without a
targetshows as a centred card, which suits a welcome and a goodbye. The last-but-one step usesadvance: { on: 'click' }, so it moves on when the person clicks the button instead of pressing Next. -
Mark the elements the steps point at.
<aside data-docent="sidebar">…</aside><button id="new-project">New project</button>target: { name: 'sidebar' }findsdata-docent="sidebar". A plain string such as'#new-project'is a CSS selector. Names are the better habit: they survive redesigns, and they say plainly that an element is part of a tour. -
Start it.
import { createTour } from '@docentjs/dom'import { welcome } from './tours'createTour(welcome).start()createTourconnects the web renderer, saves progress tolocalStorage, and follows client-side navigation. Callresume()instead ofstart()to continue from where the person left off.
Here is the same tour running on this page: