QuestionBoolean
Yes / No toggle pair implemented as an accessible radiogroup with configurable labels, size variants, and roving tabindex
QuestionBoolean renders two buttons (Yes and No) as a role="radiogroup". It is the lightest-weight question type — no options array needed, just a label.
Import
import { QuestionBoolean } from '@tour-kit/surveys';Usage
<QuestionBoolean
id="found-what-needed"
label="Did you find what you were looking for?"
yesLabel="Yes"
noLabel="No"
onChange={(value) => {
survey.answer('found-what-needed', value);
survey.complete();
}}
/>Custom labels
<QuestionBoolean
id="would-recommend"
label="Would you recommend us to a colleague?"
yesLabel="Definitely"
noLabel="Not really"
onChange={(value) => survey.answer('would-recommend', value)}
/>Controlled
const [answer, setAnswer] = useState<boolean | null>(null);
<QuestionBoolean
id="helpful"
label="Was this helpful?"
value={answer}
onChange={setAnswer}
/>Props
Prop
Type
Variants
QuestionBoolean uses booleanOptionVariants from CVA:
| Variant | Values | Default |
|---|---|---|
size | 'sm' 'md' 'lg' | 'md' |
selected | true false | false |
Size maps to button height: sm → h-8, md → h-10, lg → h-12.
Accessibility
- Container:
role="radiogroup",aria-label={label},aria-required - Options:
role="radio",aria-checked,aria-labelset toyesLabel/noLabel - Roving tabindex: only one button has
tabIndex={0}at a time - Arrow keys navigate between Yes and No; Space/Enter select
Related
Ship onboarding, not config.
npm i @tour-kit/core is MIT and free. The Pro packages work unlicensed too — a one-time $99 license removes the production watermark when you ship.
MIT-licensed — no signup, no credit card. Pay once, only when you ship.
QuestionSelect
Single-select (radiogroup) or multi-select (group of checkboxes) option list with roving tabindex, disabled option support, and size variants
QuestionMedia
Render <MediaSlot> above a question when the question has a `media?` field. No-op for questions without media, so consumers can mount it unconditionally.