<user-journey>
User journey map with SVG emotion curve, phase grid, and cross-references to personas and stories.
Overview
A web component that renders a complete user journey map with two visual layers: an SVG emotion curve that plots the user's emotional state across phases, and a detail grid showing actions, thoughts, touchpoints, pain points, and opportunities for each phase. Supports JSON loading via src attribute or programmatic data via the .phases property.
<user-journey persona="Sarah Chen" persona-id="persona-sarah-chen" story-ids="PROJ-142,PROJ-156" src="/data/journey-api-evaluation.json"> <h2 slot="title">API Platform Evaluation</h2> <p slot="summary">How a developer discovers, evaluates, and adopts our platform</p></user-journey>
Attributes
| Attribute | Values | Default | Description |
|---|---|---|---|
persona | string | — | Persona name shown in the header |
persona-id | string | — | Links the persona name to a user-persona element by id |
story-ids | string | — | Comma-separated related story IDs, rendered as fragment links |
src | string | — | URL of a JSON journey record (title, persona, personaId, summary, phases). Fetched once per value; a newer value aborts the older request. |
compact | boolean | — | Reduced spacing variant |
Slots
Content values — title and summary — are provided as named slots (there are no title or summary attributes; a title attribute on the host would only add a native tooltip). State attributes like persona, persona-id, and story-ids remain on the element.
| Slot | Expected Content | Description |
|---|---|---|
title |
<h2> or text |
Journey map heading. Defaults to "User Journey" when omitted. Also used in the phase table's accessible name. |
summary |
<p> or text |
Brief description shown below the title. |
<user-journey persona="Sarah Chen" persona-id="persona-sarah-chen" src="/data/journey.json"> <h2 slot="title">API Platform Evaluation</h2> <p slot="summary">How a developer discovers, evaluates, and adopts our platform</p></user-journey>
Data Model
Phase data can be loaded from a JSON file via the src attribute or set programmatically via the .phases property. The JSON schema supports top-level metadata plus an array of phase objects. The file is fetched once per src value (a new value aborts the previous request), and user-journey:ready fires after it renders. Every string from the data — names, emotions, ids — is rendered as text, never as markup; ids become URL-encoded fragment links.
{ "title": "API Platform Evaluation", "persona": "Sarah Chen", "personaId": "persona-sarah-chen", "summary": "How a developer discovers, evaluates, and adopts our platform", "phases": [ { "name": "Awareness", "emotion": "curious", "storyIds": ["PROJ-142"], "actions": ["Searches for solutions", "Reads comparison articles"], "thoughts": ["There must be a better way"], "touchpoints": ["Google", "Hacker News"], "painPoints": ["Too many options to compare"], "opportunities": ["Clear, developer-focused landing page"] }, { "name": "Evaluation", "emotion": "hopeful", "storyIds": ["PROJ-156"], "actions": ["Reads documentation", "Tries quick-start guide"], "thoughts": ["This looks promising"], "touchpoints": ["Docs site", "GitHub"], "painPoints": ["Missing advanced examples"], "opportunities": ["Interactive code playground"] } ]}
Each phase object supports these fields:
| Field | Type | Description |
|---|---|---|
name |
string | Phase heading (e.g., "Awareness", "Evaluation") |
emotion |
string | One of the 9 emotion values (see Emotion Scale below) |
storyIds |
string[] | Related user story IDs shown as chips in the phase header |
actions |
string[] | What the user does during this phase |
thoughts |
string[] | What the user thinks or feels |
touchpoints |
string[] | Channels and interfaces encountered |
painPoints |
string[] | Friction points and problems. Cells tinted red. |
opportunities |
string[] | Improvement ideas and design opportunities. Cells tinted green. |
Emotion Scale
The emotion field in each phase drives the Y-position of the SVG curve dot and its color. Nine values are supported, ranging from positive to negative.
| Value | Emoji | Score | Color |
|---|---|---|---|
delighted |
😄 | 0.95 | #16a34a |
satisfied |
😊 | 0.80 | #22c55e |
hopeful |
🙂 | 0.68 | #84cc16 |
curious |
🤔 | 0.55 | #eab308 |
neutral |
😐 | 0.50 | #94a3b8 |
uncertain |
😕 | 0.40 | #f97316 |
confused |
😵 | 0.30 | #fb923c |
frustrated |
😤 | 0.18 | #ef4444 |
angry |
😠 | 0.05 | #dc2626 |
The curve is rendered as an SVG with Bezier curves connecting each phase dot. The area under the curve uses a gradient fill. Three horizontal zones (green/yellow/red) provide visual context for positive, neutral, and negative emotional ranges.
Compact Variant
Add the compact attribute for tighter layouts with reduced padding, smaller fonts, and a shorter emotion curve. Useful for dashboards or pages with multiple journey maps.
<user-journey persona="Sarah Chen" compact> <h2 slot="title">Support Incident Journey</h2> <p slot="summary">From first alert to resolved incident</p></user-journey>
Programmatic Usage
For dynamic applications, set the .phases property directly instead of using a JSON file. The component re-renders automatically when phases are assigned.
const journey = document.querySelector('user-journey'); journey.phases = [ { name: 'Discovery', emotion: 'curious', actions: ['Browses landing page'], thoughts: ['Looks interesting'], touchpoints: ['Website'], painPoints: [], opportunities: ['Add video walkthrough'] }, { name: 'Onboarding', emotion: 'hopeful', actions: ['Completes setup wizard'], thoughts: ['This is straightforward'], touchpoints: ['App', 'Email'], painPoints: ['Too many steps'], opportunities: ['Reduce to 3 steps'] }, { name: 'First Success', emotion: 'delighted', actions: ['Completes first task'], thoughts: ['This actually works!'], touchpoints: ['App'], painPoints: [], opportunities: ['Celebrate with confetti'] }];
Cross-References
The <user-journey> component is designed to link to related <user-persona> and <user-story> elements on the same page:
- Persona linking — set
persona-idto theidof a <user-persona> element. The persona name renders as an anchor that scrolls to that element. - Story linking — set
story-idsto a comma-separated list of story IDs. Each ID renders as a chip link. Per-phasestoryIdsin the JSON data also render as chips in the phase header row.
<user-persona id="persona-sarah-chen" job-title="Product Manager"> <h2 slot="name">Sarah Chen</h2> <p slot="bio">Experienced PM focused on developer tools.</p></user-persona> <user-story story-id="PROJ-142" priority="high" status="in-progress" points="5"> <span slot="persona">Sarah Chen</span> <span slot="action">view project timelines in one dashboard</span></user-story> <user-journey persona="Sarah Chen" persona-id="persona-sarah-chen" story-ids="PROJ-142" src="/data/journey.json"> <h2 slot="title">Platform Evaluation</h2></user-journey>
CSS Custom Properties
| Variable | Default | Description |
|---|---|---|
--user-journey-bg |
#f8f9fa / #121212 |
Background for grid row labels and curve area |
--user-journey-card |
#ffffff / #1e1e1e |
Main card background |
--user-journey-border |
#e0e0e0 / #333333 |
Border color for card, grid lines, and curve vertical guides |
--user-journey-muted |
#666666 / #888888 |
Muted text color for labels, summary, and empty cells |
--user-journey-text |
#1a1a1a / #e8e8e8 |
Primary text color |
--user-journey-curve-stroke |
#6366f1 |
Stroke color for the emotion curve line |
--user-journey-radius |
12px |
Outer card border radius |
Events
| Event | Detail | Description |
|---|---|---|
user-journey:ready | { title, persona, phaseCount } | Once per element, after the first render. With src, after the fetched data renders (not fired if the fetch fails). Not re-fired by later renders or moves. For the 0.3.x line the deprecated un-namespaced alias journey-ready is dispatched right after, with the same detail. |
user-journey:upgraded | — | Once, in a microtask after first connect. Wait for this before assigning .data or .phases from a framework. |
user-journey:data-changed | { data, source: 'property' } | After .data is assigned |
user-journey:phases-changed | { phases, source: 'property' } | After .phases is assigned a different array |
<user-journey> follows the
HTML-first + JS-first dual-mode contract.
For reactive consumers (Montane, Lit, Solid, etc.), wait for
user-journey:upgraded before assigning .data or
.phases; use .data for the whole record
({ title, persona, phases, ... }) and .phases for fine-grained updates.
See the "Programmatic Usage" section above for the phase shape.
Accessibility
- The SVG emotion curve uses
aria-hidden="true"— it is decorative and the phase data is fully available in the grid table below - The phase grid renders as a semantic
<table>whosearia-labelis "[journey title] — phase breakdown", using the slotted title (or "User Journey") - Row and column headers (
<th>) provide screen reader context for every data cell - The first column (row labels) and corner cell are
position: stickyso they remain visible when the grid scrolls horizontally - Pain point and opportunity rows have tinted backgrounds for sighted users, plus the row label text for screen readers
- Uses
container-type: inline-sizefor responsive adjustments without media queries - Print styles remove sticky positioning for correct print layout
Related
<user-persona>— Persona cards linked viapersona-id<user-story>— Story cards linked viastory-ids<empathy-map>— Empathy maps using the same emotion vocabulary<impact-effort>— Prioritization matrix for triaging stories<story-map>— Story mapping linked viadata-journey-phase- vb-project-planning — the whole package:
import '@profpowell/vb-project-planning'registers every component