Interactive Answers
Funnel Answer
An agent's answer to where users drop off — a stepped funnel against last period, the costliest drop marked and each step opening into its top reasons.
1 variantMIT
Preview
Signup funnel
Trial signups · last 30 days vs the month before
2.7%end to end
You lose the most at connecting a source: 42% get through, down from 60%. That's 6,910 users who verified their email and stopped.
Users per step
Month before- 31%±0 pts
- 80%−1 pts
- 42%· biggest drop−18 pts
- 83%+3 pts
- 31%+2 pts
Installation
Copies the component into components/ui and installs its dependencies and theme tokens.
pnpm dlx shadcn@latest add https://tuffui.com/r/funnel-answer.jsonUsage
Pass your own data and wire the callbacks to your agent runtime.
import { Flask, PlayCircle } from "@phosphor-icons/react";
import { FunnelAnswer } from "@/components/ui/funnel-answer";
// Rendered by the agent in answer to "where do we lose users?"
export function FunnelReply({ funnel, period, setPeriod }: Props) {
return (
<FunnelAnswer
steps={funnel.steps.map((s) => ({
id: s.id,
label: s.name, // "Verified email"
count: s.users,
previous: s.usersPreviousPeriod,
dropoff: s.exitReasons && {
reasons: s.exitReasons, // [{ id, label, share: 0.46 }, …]
segments: s.bySegment, // [{ id, label: "Mobile", conversion: 0.24 }]
note: s.agentNote,
},
}))}
summary={funnel.summary}
periods={[
{ value: "7d", label: "7 days" },
{ value: "30d", label: "30 days" },
]}
period={period}
onPeriodChange={setPeriod}
// Open the costliest drop straight away.
defaultExpandedId={funnel.worstStepId}
followUps={[
{ id: "experiment", title: "Draft an experiment", icon: Flask },
{ id: "sessions", title: "Show sessions", icon: PlayCircle },
]}
onFollowUp={(_, prompt) => sendMessage(prompt)}
/>
);
}Props
| Prop | Type | Default | Description |
|---|---|---|---|
| steps* | FunnelStep[] | — | Funnel steps in order. Each is a centered bar with its count and change against `previous`; conversion to the next step sits between rows. |
| highlightedId | string | null | — | Step whose drop to the next step is marked as the biggest. Omitted, it's the step whose conversion fell most against the previous period, or the lowest conversion without one. `null` marks nothing. |
| expandedId | string | null | — | Controlled open step. An open step shows why people left before the next step: top three reasons as bars, an optional segment split and the agent's note. |
| defaultExpandedId | string | null | null | Starting open step when uncontrolled. |
| onExpandedChange | (id: string | null) => void | — | Called when a step is clicked or picked with Enter or Space. Clicking the open step closes it. The last step has no drop and doesn't open. |
| periods | FunnelPeriod[] | — | Options for the period toggle above the funnel. Two or more show it. |
| period | string | — | Selected period. Pass the matching `steps`; bars and numbers glide to the new values. |
| onPeriodChange | (period: string) => void | — | Called from the period toggle. |
| summary | React.ReactNode | — | Agent text above the funnel. Cross-fades when the period changes. |
| followUps | PromptSuggestion[] | — | Follow-up chips under the answer, e.g. "Draft an experiment". |
| onFollowUp | (suggestion, prompt: string) => void | — | Called with the chip and the text to send. |
| icon | Icon | FunnelSimple | Header icon, a Phosphor icon. |
| title | React.ReactNode | "Signup funnel" | Header title. |
| subtitle | React.ReactNode | "48,210 users · 6 steps" | Secondary line under the title. |
| chartTitle | string | "Users per step" | Heading above the funnel, also its accessible name. |
| previousLabel | string | "Previous period" | Legend text for the ghost bars. |
| formatCount | (count: number) => string | "48,210" | Formats user counts. |
| scale | "sqrt" | "linear" | "sqrt" | Bar width scale. `sqrt` keeps late steps readable when the top of the funnel is far larger; `linear` is literal. |
| intro | boolean | true | Rows rise in one after another and bars grow from the center on mount. Skipped with reduced motion. |
| className | string | — | Extra classes for the root element. |
type FunnelStep = {
id: string;
label: string; // "Verified email"
count: number; // users who reached the step
previous?: number; // previous period, drawn as a ghost bar
dropoff?: FunnelDropoff; // why people left before the next step
};
type FunnelDropoff = {
reasons: { id: string; label: string; share: number }[]; // top 3 shown
segments?: { id: string; label: string; conversion: number }[];
note?: React.ReactNode;
};
type FunnelPeriod = { value: string; label: string };