Conditional Branch
Open in playgroundBinary or four-way choice that reveals a tailored follow-up per path. Lets the assistant fork an interview on the first answer instead of asking everything of everyone.
Preview
Usage
import { ConditionalBranch } from "@/components/socratic-ui/conditional-branch";
const [value, setValue] = useState({ selectedId: null, followUpValue: null });
<ConditionalBranch
question="Do you have existing users?"
options={[
{
id: "yes",
title: "Yes",
followUp: {
kind: "single-select",
question: "Roughly how many active users?",
options: [{ title: "< 100" }, { title: "100–1k" }],
},
},
{
id: "no",
title: "No",
followUp: {
kind: "text",
question: "Who's your initial target audience?",
},
},
]}
value={value}
onChange={setValue}
/>
API Reference
| Prop | Type | Default |
|---|---|---|
questionrequiredThe headline shown above the branch options. | string | — |
subtitleOptional supporting copy beneath the question. | string | — |
optionsrequired2–4 primary branch options. Each can carry an optional follow-up (`single-select` or `text`) that appears beneath the picked branch. | { id: string; title: string; subtitle?: string; followUp?: FollowUp }[] | — |
valuerequiredThe primary selection and its associated follow-up answer. Switching branches clears the follow-up. | { selectedId: string | null; followUpValue: string | null } | — |
onChangerequiredCalled whenever the branch or follow-up answer changes. | (value: { selectedId: string | null; followUpValue: string | null }) => void | — |
numberOptional leading question number, e.g. "01". | string | — |
motionOpt-in entrance animation config. Omit for static rendering; pass `{ enabled: true }` (or a preset from `motion.ts`) to animate in on mount. | SocraticMotion | — |