<user-story>
Displays Agile user stories in the classic 'As a / I want / so that' format with priority, status, and story points.
Overview
A web component that renders user stories in the standard Agile format: "As a [persona], I want [action] so that [benefit]." Includes visual badges for priority, status, and story points, plus slotted sections for acceptance criteria, tasks, and notes. Designed for sprint planning boards, backlog views, and design documentation.
<user-story persona-id="persona-sarah" priority="high" status="in-progress" points="5" epic="Dashboard" story-id="PROJ-142"> <span slot="persona">Product Manager</span> <span slot="action">view all project timelines in one dashboard</span> <span slot="benefit">I can quickly identify bottlenecks and reallocate resources</span> <ul slot="acceptance-criteria"> <li>Dashboard loads within 2 seconds</li> <li>All active projects are displayed</li> <li>Timeline view is zoomable</li> </ul> <ul slot="tasks"> <li>Design dashboard wireframe</li> <li>Implement timeline API endpoint</li> <li>Build frontend grid layout</li> </ul> <p slot="notes">Consider using virtual scrolling for large project lists.</p></user-story>
Attributes
| Attribute | Values | Default | Description |
|---|---|---|---|
heading-level | number | — | Level (1–6) of the Acceptance Criteria / Tasks / Notes headings. Default: one below the nearest preceding heading on the page (the slotted title is only shown in minimal mode, which has no sections). |
persona-id | string | — | Links to a user-persona element by id. Without a persona slot, the "As a…" text uses that persona's job-title (live-updating; a legacy non-ARIA role attribute is also read). |
priority | "critical", "high", "medium", "low" | medium | Story priority level |
status | "backlog", "to-do", "in-progress", "review", "done" | backlog | Workflow status |
points | string | — | Story point estimate (badge reads "[n] story points" to screen readers) |
epic | string | — | Parent epic label |
story-id | string | — | Ticket or story identifier; sets the HTML id on first connect when none is set |
detail | "full", "compact", "minimal" | full | Detail level. minimal renders a button that opens the full story in a dialog. |
compact | boolean | — | Alias for detail=compact |
src | string | — | URL of a JSON story record. Fetched once per value; a newer value aborts the older request. |
Slots
| Slot | Expected Content | Description |
|---|---|---|
persona |
<span> or text |
The "As a..." role or persona name (e.g., "Product Manager") |
action |
<span> or text |
The "I want..." action description |
benefit |
<span> or text |
The "so that..." benefit. When omitted, the benefit clause is hidden. |
acceptance-criteria |
<ul> or <ol> |
Definition of done checklist. Displayed with a green accent icon. |
tasks |
<ul> or <ol> |
Implementation tasks. Displayed with a purple accent icon. |
notes |
<p> or text |
Additional notes or context. Displayed with an amber accent icon. |
Detail Levels
The detail attribute controls how much content the card displays. Three levels support different use cases from dense kanban boards to full documentation.
| Value | Shows | Use Case |
|---|---|---|
full |
Header, statement, all sections (with empty fallbacks) | Documentation pages, standalone story views |
compact |
Header, statement, sections only if populated | Story map columns, backlog lists |
minimal |
Story ID + title only. Clickable — opens full detail in a <dialog>. |
Kanban boards, impact/effort matrix, dense grids |
<user-story story-id="PROJ-142" detail="minimal"> <span slot="persona">Product Manager</span> <span slot="action">see all project timelines in a unified dashboard</span></user-story>
Click to Expand
Minimal cards render as a <button> (named "[story-id]: [title]", with aria-haspopup="dialog"). Clicking it or pressing Enter or Space opens a native modal <dialog> showing the full story, labelled by its <h2> title. Each story owns one dialog: it is removed from the document when it closes or when the story is removed. The dialog uses VB’s built-in dialog CSS for sizing, backdrop, and animation. You can also call story.showDetail() programmatically.
const story = document.querySelector('user-story[story-id="PROJ-142"]');story.showDetail(); // Opens modal dialog with full detail
JSON Loading
Load story data from a JSON file using the src attribute. Scalar fields map to attributes; text and list fields create the slotted persona, action, benefit, title, acceptance criteria, tasks, and notes children (authored children are kept). The file is fetched once — moving the card (for example between kanban columns) does not refetch — and user-story:ready fires after the data renders.
<user-story src="/api/stories/PROJ-142.json" detail="full"></user-story>
{ "storyId": "PROJ-142", "title": "Dashboard timeline view", "persona": "Product Manager", "action": "see all project timelines in a unified dashboard", "benefit": "I can quickly identify bottlenecks", "priority": "high", "status": "in-progress", "points": "8", "epic": "Dashboard", "acceptanceCriteria": [ "Dashboard loads within 2 seconds", "All active projects displayed" ], "tasks": ["Design mockups", "Implement timeline"], "notes": "Consider virtual scrolling for performance."}
Slot-Based Authoring
Content values — persona, action, and benefit — are provided as named slots. State attributes like priority, status, points, and story-id remain on the element. This separation keeps content in the DOM and metadata in attributes.
<user-story story-id="PROJ-142" priority="high" status="in-progress" points="5"> <span slot="persona">Product Manager</span> <span slot="action">see all project timelines in a unified dashboard</span> <span slot="benefit">I can quickly identify bottlenecks</span> <ul slot="acceptance-criteria"> <li>Dashboard loads within 2 seconds</li> </ul></user-story>
Priority Variants
The priority attribute controls the colored badge in the story header. Here are three stories showing different priority and status combinations in compact mode.
| Value | Label | Color |
|---|---|---|
critical |
Critical | #dc2626 (red) |
high |
High | #ea580c (orange) |
medium |
Medium | #ca8a04 (amber) |
low |
Low | #16a34a (green) |
<user-story priority="critical" status="to-do" story-id="SEC-301"> <span slot="persona">Security Engineer</span> <span slot="action">receive alerts for authentication failures</span> <span slot="benefit">I can respond to potential breaches immediately</span></user-story>
Status Variants
The status attribute controls the workflow badge in the story header.
| Value | Label | Color |
|---|---|---|
backlog |
Backlog | #6b7280 (gray) |
to-do |
To Do | #3b82f6 (blue) |
in-progress |
In Progress | #8b5cf6 (purple) |
review |
Review | #f59e0b (amber) |
done |
Done | #22c55e (green) |
JavaScript API
The component exposes two methods for programmatic status and priority updates. Both update the attribute and dispatch a corresponding event. The un-namespaced names used before 0.3.0 (status-changed, priority-changed, story-ready) still fire as deprecated aliases throughout 0.3.x.
| Method | Argument | Description |
|---|---|---|
updateStatus(status) |
One of: backlog, to-do, in-progress, review, done |
Updates the status badge and fires user-story:status-changed |
updatePriority(priority) |
One of: critical, high, medium, low |
Updates the priority badge and fires user-story:priority-changed |
const story = document.querySelector('user-story[story-id="PROJ-142"]'); // Move to reviewstory.updateStatus('review'); // Escalate prioritystory.updatePriority('critical'); // Listen for changesstory.addEventListener('user-story:status-changed', (e) => { console.log(`${e.detail.storyId} moved to ${e.detail.status}`);});
Property API (JS-first)
The whole story — state and slotted content — can be set in one assignment, useful when a reactive framework or kanban-board owns the data.
| Property | Type | Description |
|---|---|---|
.data | { storyId?, personaId?, priority?, status?, points?, epic?, detail?, persona?, action?, benefit?, title?, acceptanceCriteria?, tasks?, notes? } | Sets state attributes and creates slotted children for any fields not already present (authored content wins). Idempotent. |
showDetail() | method | Open this story at full detail in a modal dialog (see Click to Expand). |
updateStatus(status) / updatePriority(priority) | method | Set the attribute and fire user-story:status-changed / user-story:priority-changed. Unknown values are ignored. |
const us = document.createElement('user-story');us.data = { storyId: 'PROJ-200', priority: 'high', status: 'in-progress', points: 5, persona: 'Product Manager', action: 'filter projects by date range', benefit: 'I can spot bottlenecks faster', acceptanceCriteria: [ 'Date pickers default to last 30 days', 'Empty state shown when no matches', ],};document.body.appendChild(us);
Reading .data back returns the current shape. See the Data API concepts guide.
Assigning .data fires user-story:data-changed; frameworks should wait for user-story:upgraded first. All events are listed under Events below.
CSS Custom Properties
| Variable | Default | Description |
|---|---|---|
--user-story-bg |
#ffffff / #1e1e1e |
Card background color |
--user-story-text |
#1a1a1a / #e8e8e8 |
Primary text color |
--user-story-muted |
#666666 / #888888 |
Secondary/muted text color |
--user-story-border |
#e0e0e0 / #333333 |
Card and section border color |
--user-story-accent |
#0066cc / #6b9fff |
Accent color for keywords and epic badge |
--user-story-card-bg |
#f8f9fa / #252525 |
Header background color |
--user-story-highlight |
rgba(0, 102, 204, 0.08) / rgba(107, 159, 255, 0.15) |
Persona text highlight and epic badge background |
--user-story-radius |
12px |
Outer card border radius |
Events
| Event | Detail | Description |
|---|---|---|
user-story:ready | { id, persona, action, benefit, priority, status, points } | Once per element, after the first render. With src, after the fetched data renders (not fired if the fetch fails). Not re-fired by attribute changes or moves. For the 0.3.x line the deprecated un-namespaced alias story-ready is dispatched right after, with the same detail. |
user-story:status-changed | { status, storyId } | Fired when updateStatus() is called with a known status. For the 0.3.x line the deprecated un-namespaced alias status-changed is dispatched right after, with the same detail. |
user-story:priority-changed | { priority, storyId } | Fired when updatePriority() is called with a known priority. For the 0.3.x line the deprecated un-namespaced alias priority-changed is dispatched right after, with the same detail. |
user-story:upgraded | — | Once, in a microtask after first connect. Wait for this before assigning .data from a framework. |
user-story:data-changed | { data, source: 'property' } | After .data is assigned |
Accessibility
- The full and compact card is an
<article>witharia-label="User story: [story-id]"(or "User story" without an id) - The minimal card is a real
<button>named "[story-id]: [title]" witharia-haspopup="dialog"; Enter and Space open the detail dialog - On a board (a minimal card directly inside a
<drag-surface>, as in<kanban-board>,<story-map>or<impact-effort>) the card itself is the single tab stop and the inner button leaves the tab order. Enter opens the detail dialog; Space grabs the card for keyboard reordering; while grabbed, the arrow keys move it, Space or Enter drops it and Escape cancels. A click opens the dialog. - Priority and status badges use color plus text labels — never color alone
- The story points badge shows the number and includes visually hidden text, so it reads as "[n] story points"
- The Acceptance Criteria, Tasks, and Notes sections each have a visible
<h3>heading for screen reader navigation - Respects
prefers-reduced-motion: reduceby disabling hover transitions - Responsive layout stacks header badges vertically at narrow viewports (<480px)
Related
<user-persona>— Persona cards that stories reference<user-journey>— Journey maps that link to story IDs<empathy-map>— Empathy maps for understanding user needs<impact-effort>— Prioritization matrix for draggable story cards<story-map>— Horizontal story mapping with activity columns- vb-project-planning — the whole package:
import '@profpowell/vb-project-planning'registers every component