Funnel

Slant / Charts

Conversion steps with counts, percentage changes and the largest drop.

Demo

Usage

@tuttn/slant
import { Funnel } from '@tuttn/slant'

const steps = [
  { label: 'Visited', value: 8400 },
  { label: 'Started', value: 4200 },
  { label: 'Reviewed', value: 1950 },
  { label: 'Completed', value: 760 },
]

<Funnel data={steps} label="Completion funnel"
  format={value => value.toLocaleString('en')} />

// Change the highlight and the height of the bars.
<Funnel data={steps} label="Completion funnel" tone="warning"
  className="completion-funnel" />

.completion-funnel { --sl-funnel-height: 12rem; }

Props

PropTypeDefaultDescription
datareadonly FunnelDatum[]—The journey's steps, in order. Counts may increase as well as decrease.
labelstring—The ordered list's accessible name.
format(value: number) => stringStringFormats each count; percentages are calculated from the underlying numbers.
toneTone'accent'Highlights the largest percentage drop from the preceding step.
…restOmit<HTMLAttributes<HTMLDivElement>, 'children'>—className, style, other attributes and the ref reach the outer div.

Accessibility

  • The list is named by label; each step exposes its count and signed change as readable text.
  • Largest drop is written out and marked with a pixel, so colour is not the only cue.
  • Long journeys scroll inside a keyboard-focusable viewport without widening the page.

Counts and changes

Pass steps in journey order. Bars scale to the largest count, while each percentage compares with the immediately preceding step. A smaller count shows a negative change and a larger count shows a positive change. The largest percentage drop receives the chosen tone, a slanted pixel and a text label; ties highlight the first drop. A journey with no decreases has no highlighted step.

Negative and non-finite counts read as zero. A step following zero has no meaningful percentage baseline, so its change is an em dash. An increase too large to represent as a finite percentage also uses the dash. Zero stays zero in the artwork; it is never given a decorative minimum bar. An empty array shows the kit's empty-chart message.

Layout and accessibility

The data is an ordered list with visible labels, counts and changes. Screen readers receive a change relative to the previous named step, and the largest drop is identified in words as well as colour. There are no hidden values behind tooltips and no chart-specific keyboard controls. Steps follow the reading direction, including RTL.

Columns share the available width, with a 60px minimum each. Long journeys scroll inside their container; an overflowing scroll area takes keyboard focus. Set --sl-funnel-height to change the bars' height from 10rem. Use BarChart for unrelated categories or multiple series.