Single Select
Open in playgroundPick one option from a list. Supports an optional freeform note for extra context, and tapping a selected option clears it.
Preview
Usage
import { SingleSelect } from "@/components/socratic-ui/single-select";
const [value, setValue] = useState<string | null>(null);
<SingleSelect
question="How are you building this product?"
options={[
{ title: "Solo founder" },
{ title: "Co-founding team" },
]}
value={value}
onChange={setValue}
/>
API Reference
| Prop | Type | Default |
|---|---|---|
questionrequiredThe headline shown above the options. | string | — |
subtitleOptional supporting copy beneath the question. | string | — |
optionsrequiredThe list of selectable options. | { title: string; subtitle?: string }[] | — |
valuerequiredTitle of the selected option (single mode), array of titles (multi mode when `allowMultiple` is set), or null. | string | string[] | null | — |
onChangerequiredCalled when the selection changes. Tapping a selected option in single mode clears it. | (value: string | string[] | null) => void | — |
allowMultipleWhen true, the component upgrades to multi-select on the second pick. `value` becomes `string[]` and the optional `multiValue` / `onMultiChange` props control the array. | boolean | — |
suggestedSoft-cap hint shown in the footer ("N suggested"). Exceeding it tints the count but does not block further selections. | number | — |
maxHard cap on selections in multi-mode. Unselected options dim once the cap is reached. | number | — |
freeformPlaceholderRenders an extra textarea beneath the options. Defaults to "Any extra context…"; pass `false` to hide. | string | false | — |
freeformValueControlled value for the freeform textarea. | string | — |
onFreeformChangeControlled setter for the freeform textarea. | (value: string) => void | — |
iconLayoutHow icons align relative to their label. `vertical` stacks icon above label for a tile-style layout. | "horizontal" | "vertical" | "horizontal" |
iconAlignmentHorizontal alignment of the icon within its slot. Only applies when `iconLayout` is `"vertical"`. | "left" | "center" | "left" |
motionOpt-in entrance animation config. Omit for static rendering; pass `{ enabled: true }` (or a preset from `motion.ts`) to animate in on mount. | SocraticMotion | — |