Question Flow
tool-ui/question-flowFreeBlock
Multi-step guided questions with branching.
See it running
Open the demo on tool-ui
www.tool-ui.com/components/question-flowInstall it
npx shadcn@latest add https://www.tool-ui.com/r/question-flow.jsonSource
1"use client";23import {4 useMemo,5 useState,6 useCallback,7 useRef,8 useEffect,9 Fragment,10} from "react";11import type { KeyboardEvent } from "react";12import type {13 QuestionFlowProps,14 QuestionFlowProgressiveProps,15 QuestionFlowUpfrontProps,16 QuestionFlowReceiptProps,17 QuestionFlowOption,18} from "./schema";19import { cn, Button, Separator } from "./_adapter";20import { Check, ChevronLeft } from "lucide-react";2122interface SelectionIndicatorProps {23 mode: "single" | "multi";24 isSelected: boolean;25 disabled?: boolean;26}2728interface ProgressBarProps {29 current: number;30 total: number;31}3233function ProgressBar({ current, total }: ProgressBarProps) {34 return (35 <div36 className="flex h-1.5 gap-1"37 role="progressbar"38 aria-valuenow={current}39 aria-valuemin={1}40 aria-valuemax={total}41 >42 {Array.from({ length: total }).map((_, i) => (43 <div44 key={i}45 className="relative flex-1 overflow-hidden rounded-full bg-muted"46 >47 <div48 className={cn(49 "absolute inset-0 origin-left rounded-full bg-primary",50 "motion-safe:transition-transform motion-safe:duration-300 motion-safe:ease-[var(--cubic-ease-in-out)]",51 i < current ? "scale-x-100" : "scale-x-0",52 )}53 />54 </div>55 ))}56 </div>57 );58}5960function SelectionIndicator({61 mode,62 isSelected,63 disabled,64}: SelectionIndicatorProps) {65 const shape = mode === "single" ? "rounded-full" : "rounded";6667 return (68 <div69 className={cn(70 "flex size-4 shrink-0 items-center justify-center border-2",71 "motion-safe:transition-colors motion-safe:duration-200",72 shape,73 isSelected && [74 "border-primary bg-primary text-primary-foreground",75 "motion-safe:animate-in motion-safe:fade-in motion-safe:zoom-in-75 motion-safe:duration-300 motion-safe:ease-out",76 ],77 !isSelected && "border-muted-foreground/50",78 disabled && "opacity-50",79 )}80 >81 {mode === "multi" && isSelected && (82 <Check83 className="size-3 motion-safe:animate-in motion-safe:fade-in motion-safe:zoom-in-75 motion-safe:delay-75 motion-safe:duration-200 motion-safe:fill-mode-both"84 strokeWidth={3}85 />86 )}87 {mode === "single" && isSelected && (88// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from tool-ui
All 27 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Approval Cardapproval-card | tool-ui | Blocks | Free | 2 deps · 11 files | |
| Audioaudio | tool-ui | Blocks | Free | 2 deps · 9 files | |
| Chartchart | tool-ui | Blocks | Free | 2 deps · 8 files | |
| Citationcitation | tool-ui | Blocks | Free | 2 deps · 15 files | |
| Code Blockcode-block | tool-ui | Blocks | Free | 3 deps · 11 files | |
| Code Diffcode-diff | tool-ui | Blocks | Free | 3 deps · 10 files | |
| Data Tabledata-table | tool-ui | Blocks | Free | 1 dep · 17 files | |
| Geo Mapgeo-map | tool-ui | Blocks | Free | 4 deps · 12 files |
