ComponentsIconsGuidesExamplesGetting started
ComponentsIconsGuidesExamplesGetting started
GitHub repository

Steps

A vertical trace of a task as it runs: statuses, durations, and stages that open while they work and close when they are done.

c2-steps is a vertical list of c2-step rows. Each row is a marker, a label, an optional dimmed detail beside it and trailing text at the end — a duration, a count, a timestamp.

A step with sub-steps is a group, and a group is a disclosure: its own row is the summary and its sub-steps are the detail. There is no second element to learn — the same tag is a leaf or a group depending on what is inside it. That is what makes a long run readable: the list keeps the shape of the task while the detail of each stage stays one click away.

Every step is a row, and every row is visible. A group starts expanded and nothing ever folds one away on its own: the chevron is there for the reader, and collapsed in the markup starts a stage folded. The run only ever brings a folded stage back into view — one the reader put away reopens when it starts running (running, current) or when something in it goes wrong (error, warning).

A step is one row. Label, detail and trailing text sit on a single line and truncate with an ellipsis rather than wrapping, so a hundred-step trace stays scannable. A sub-step is indented by exactly the marker’s width plus the row gap, so its marker lands under its parent’s label — that alignment is all the nesting needs, and nothing else is drawn for it. --c2-step__guide--width: 1px adds file-tree rules if you want them, and the toggle slot adds a chevron; both are off by default.

The detail sits beside the label by default, which is what a trace wants — a path or an id read as an aside to the name. --c2-step__text--flex-direction: column puts it on its own line underneath instead, which is what a wizard’s descriptions want. That one variable is the whole switch: the gap between them and their alignment follow it. Two lines on purpose, and each of them is still one line.

A parent takes the status of the worst thing inside it when it authors none of its own, so a stage reports that it is running, or that something under it failed, without you setting it.

Author it either way, and mix them freely: slot c2-step children, or hand c2-steps a steps array of { id, label, detail, trailing, status, children } and it renders the tree itself. The array wins when both are present.

The connector rail is off by default, because a trace does not want one. Give --c2-step__rail--width a width and a stepper gets its rail. Numbering follows the tree: marker="number" draws a dotted path, so the first child of the third step reads 3.1 rather than a second 1.

Installation

npm install @c2n/steps

Usage

1lintpassed2tsconfig.lib.jsontype-check3testqueued

Driving a run

A trace usually arrives as data. Hand over the shape of the task once, then tick one step at a time — updateStep finds a step by id and redraws without rebuilding the array, which is what a runner wants when it fires hundreds of times:

const trace = document.querySelector('c2-steps')

trace.steps = [
  { id: 'build', label: 'build', children: [{ id: 'install', label: 'install dependencies' }, { id: 'compile', label: 'compile' }] },
  { id: 'test', label: 'test', children: [{ id: 'unit', label: 'unit' }, { id: 'e2e', label: 'e2e' }] },
]

// The parent stage rolls the status up on its own.
trace.updateStep('install', { status: 'running' })
trace.updateStep('install', { status: 'success', trailing: '19 s' })

Nothing stops you doing the same to slotted markup — a c2-step is an element, and setting status on it is enough. The parent list watches the attribute, so a stage rolls its status up from that alone:

document.querySelector('c2-step[data-id="e2e"]').status = 'running'

Watching a run

A static example can only show one frame of a trace. Press Run the task and watch the rows arrive:

Run the taskResetCollapse allExpand all

Each step is appended the moment the runner reaches it, so you are watching rows arrive rather than a list redraw. A stage takes its status from the steps inside it, and gives one beat when it settles.

What moves while it runs

A trace being written in front of you should look like it. Two things move, and neither needs anything from you:

  • A step that arrives while the list is already on screen grows into place from a collapsed row and fades in, rather than snapping the rows below it down the page. A step drawn with the list does not — a whole trace fading in at once is a page loading, not an arrival.
  • A status that settles gives its marker one beat. Again only a status that actually changed: a trace rendered complete sits still.

--c2-step--enter-duration (260ms) and --c2-step--enter-translate (-4px) shape the arrival, and 0s turns it off; --c2-step--transition-duration (150ms) covers the colour transitions and the beat. prefers-reduced-motion: reduce turns all of it off.

Give every node a stable id. That is what lets the list reuse a step’s DOM across renders instead of rebuilding it — without one a step is identified by its position, so inserting anywhere but the end recreates the rows after it, and they all animate in as if they were new.

collapseAll() folds every group away, leaving the top-level stages; expandAll() brings them all back.

A group announces itself when it is folded away or brought back. The event bubbles, so one listener on the list hears them all:

trace.addEventListener('step-toggle', (event) => {
  console.log(event.target.label, event.detail.path, event.detail.collapsed)
})

Rendering a row yourself

Everything the markup fills with a slot, the data-driven mode fills with a renderer — the two modes have the same reach, and a renderer is simply the function form of the slot:

Part of the rowIn markupFrom steps
the icon<span slot="marker">renderMarker
the primary text<span slot="label">renderLabel
the dimmed text beside it<span slot="detail">renderDetail
the text at the end<span slot="trailing">renderTrailing
the disclosure affordance<span slot="toggle">renderToggle
all of the text at once—renderItem

Every renderer is handed the node, its depth, its position, its dotted path and the status actually in effect, and returns anything Lit renders — a string, an <svg>, an icon element:

import '@c2n/feather-icons/icons/alert-triangle.js'
import { html } from 'lit'

// An icon of your own instead of the status glyph, per step.
trace.renderMarker = ({ node, status }) =>
  status === 'warning' ? html`<c2-feather-alert-triangle></c2-feather-alert-triangle>` : node.icon

// A duration that ticks while the step is running.
trace.renderTrailing = ({ node, status }) => (status === 'running' ? elapsedSince(node.startedAt) : node.trailing)

renderItem takes over the row’s text — it overrides renderLabel, renderDetail and renderTrailing. The marker and the disclosure are their own columns rather than part of that text, so renderMarker and renderToggle still apply alongside it:

trace.renderItem = ({ node }) => html`<a href=${node.href}>${node.label}</a> <c2-badge>${node.count}</c2-badge>`
trace.renderMarker = ({ node }) => node.icon
escAccordionConnected, animated panels with shared borders and single or multiple expansion.LayoutArea chartA line chart with the region under each line filled — every line-chart attribute, plus a fill opacity.ChartAttachmentFile and image attachments with metadata, upload progress, failure states, and actions.Data displayAutocompleteSearchable combobox for local or remote items with customizable list rows.InputsAvatarImage, initials or icon for a person, with status dot and badge.Data displayBadgeTinted pill for status text, counts and dots, optionally pinned to a corner of another element.Data displayBar chartBars over categories or time buckets, with several series drawn side by side within each band.ChartBorder BeamA decorative beam that travels around the border of any positioned container.LayoutBreadcrumbNavigation trail of link buttons with separators, a current page and optional collapsing.NavigationButtonThemeable button with slots for text, prefix, suffix and running icons.ButtonsButton GroupJoined actions and polished segmented controls with single or multiple selection.ButtonsCandlestick chartAn ECharts OHLC chart for market sessions and other open-close ranges, with semantic positive and negative colours.ChartCardGroups related content and actions on a single bordered surface.LayoutCascaderSelect a value from related, multi-level data in one floating panel.InputsChat InputAuto-growing message composer with keyboard submission, toolbar actions and native form support.ChatChat MessageFlexible message row for conversations, assistant answers and activity updates.ChatCheckboxNative checkbox behaviour in a quiet, themeable box with an opt-in hover layer.InputsCode EditorEditable, syntax-highlighted source field on CodeMirror 6, themed entirely through CSS variables.InputsCode ViewerSyntax-highlighted code with line numbers, copy button and dark mode, powered by shiki.Data displayColor AreaTwo-dimensional area for picking saturation and value of a colour.InputsColor SelectColour swatch that opens a full picker built from area and slider.InputsColor SliderHorizontal slider for choosing a hue from 0 to 360.InputsCopy ButtonButton that copies text to the clipboard — the element it sits in, another element by id, or a literal string.ButtonsDashboardGrid of resizable panes, dragged by the edges they share.LayoutDate InputForm-associated single-date input with native picker, constraints, helper text and error states.InputsDate SelectorAccessible one- or two-month calendar for choosing a date range.InputsDetailsCollapsible disclosure built on native details and summary.LayoutGauge chartA focused radial KPI gauge drawn by ECharts, with a configurable scale, progress arc and pointer.ChartHeaderArranges brand, navigation, actions and a mobile trigger in a reusable site shell.LayoutIcon ButtonRound, hoverable button wrapping a slotted SVG icon.ButtonsKbdKeyboard key label for shortcuts and command hints, with the semantics of the native kbd element.Data displayLabelCaption that names and activates the control referenced by its for attribute, with a required marker.InputsLine chartA line chart over a time or numeric x axis, drawn on canvas by uPlot, with series declared as children.ChartLink ButtonText-styled control for link and navigation actions, rendered as a real anchor or a button.NavigationListVertical list container with single or multiple selection.Data displayList ItemSelectable row with icon slots, used on its own or as the option of list and select.Data displayMenuCommands, links, checkboxes and submenus in a popover anchored to a trigger.NavigationModalDialog built on the native dialog element: focus trap, backdrop, Escape, title, body and footer.FeedbackNavigation MenuSite navigation bar whose triggers open panels of links below the header.NavigationNumber InputForm-associated numeric input with native validation, step controls, adornments and helper states.InputsOverlayAnchored popup built on the browser Popover API, positioned with floating-ui.FeedbackPaginationPage navigation in three layouts: numbered pages, a simple page status, or a table-footer row with rows-per-page.NavigationPie chartA pie or donut chart drawn by ECharts, where one row is one slice and label-field names it.ChartProgressLinear progress bar, indeterminate or filling to a value, with an optional label and count.FeedbackQR CodeGenerate accessible, themeable QR codes locally as crisp SVG graphics.Data displayQuestionnaireA multi-step single- and multiple-choice flow with validation, shortcuts and form submission.InputsRadar chartCompare several profiles across the same set of normalized indicators.ChartRadioRadio options built on native inputs, grouped into one value with keyboard navigation.InputsRateAccessible star rating input with hover preview, keyboard control and optional half values.InputsReorder ListReorder a vertical queue with pointer or keyboard input while the application owns persistence.Data displayScatter chartAn ECharts scatter plot for finding relationships, clusters and outliers across two numeric measures.ChartSelectDropdown that pairs a themeable trigger with an anchored list of c2-list-item options.InputsSeperatorHorizontal or vertical rule with an optional label, for dividing content and toolbars.LayoutSheetDialog pinned to an edge of the screen, for content that complements the page rather than interrupting it.FeedbackSide NavResponsive navigation drawer beside the page: pushes the content on large screens, slides over it with a backdrop on small ones.NavigationSkeletonPlaceholder block standing in for content that has not arrived, in three shapes and three animations.FeedbackSliderRange input with a themeable track, thumb, step ticks and value bubble.InputsSparklineA chromeless trend line sized for a table cell, a list row or the trend slot of a c2-stat.ChartSpinnerCircular progress indicator, indeterminate or showing a value, with optional text.FeedbackStatDisplays a KPI with an optional icon, trend and supporting description.Data displayStatus PanelCommunicate empty states, operation outcomes and recoverable errors with clear next steps.FeedbackStepsA vertical trace of a task as it runs: statuses, durations, and stages that open while they work and close when they are done.Data displaySwitchOn/off toggle on a native switch input, with label, description and thumb icons.InputsTableVirtualized data grid with declarative columns, sorting, selection, pinning and resizing.Data displayTabsTab strip that shows one content panel at a time.NavigationText FieldSingle-line input with icon slots, clear button, helper and error text, and a character counter.InputsTextareaMultiline text input with resizing, helper and error text, and a character counter.InputsTheme SelectColour-theme switcher: click to step to the next mode, hover for the full menu.InputsToastNotification cards and a manager for stacked, queued notifications with independent lifetimes.FeedbackTooltipContextual hint shown when its target is hovered or focused, rendered in the top layer.FeedbackTreeHierarchical tree view with expansion, selection, checkboxes and lazy loading.Data displayUploadDrag-and-drop file selection with validation, upload progress, retry, cancellation, and attachment results.InputsVirtual ListWindowed list with built-in search, sorting, selection and an async data source.Data displayFeather Icons287 open-source Feather icons, one web component each.IconsMat Icon2,234 Material Icons ligatures rendered through a single element.IconsPhosphor Icons1,512 flexible icons in six weights, one web component each.IconsThemingTheme every c2n component from a handful of design tokens with @c2n/theme, or reach for any component variable directly.GuideFrameworksUse the components from React, Vue, Angular, Svelte, Lit or plain HTML — typed events, generated template types, and the one piece of configuration each framework needs.GuideUsing c2n in an applicationThe workflow behind every c2n app: load the theme once, use c2-* tags directly, and turn every repeated pattern into a small variant or composed component.GuideAI toolsGive Claude Code, Codex or Google Antigravity the c2n skill, live component APIs, examples and application conventions.Guide