TBX Docs
ExercisesCatalogue

YesNo

True/False or Yes/No questions

YesNo presents a list of statements with Yes/No (or custom labels) buttons. Ideal for fact-checking and true/false exercises.

Import

import { YesNo } from '@bside-tech/tbx-ui/components';

Example

Answer all questions below using a simple Yes or No.
Select true or false for each statement.
  • The Earth is flat.
    Answer for: The Earth is flat.
  • Water boils at 100°C at sea level.
    Answer for: Water boils at 100°C at sea level.
  • JavaScript and Java are the same language.
    Answer for: JavaScript and Java are the same language.
<YesNo
  entries={[
    { text: "The Earth is flat.", answer: false },
    { text: "Water boils at 100°C at sea level.", answer: true },
    { text: "JavaScript and Java are the same language.", answer: false },
  ]}
/>

Props

Prop

Type

Labels

Override labels via the labels prop. Supported keys: true, false (Yes/No buttons), check, reset (action buttons), results (e.g. "correct" in "3 / 5 correct"). Default for buttons: { true: "Yes", false: "No" }.

<YesNo
  entries={[
    { text: "The sky is blue.", answer: true },
    { text: "2 + 2 = 5.", answer: false },
  ]}
  labels={{
    true: "Agree",
    false: "Disagree",
    check: "Verify",
    reset: "Retry",
    results: "correct",
  }}
/>

Style

Tailwind v4 is available for all customisations. Pass classes via the classNames prop, or override CSS variables for fine-grained control.

CSS Classes

KeyElement
rootRoot wrapper
listQuestion list (ul)
itemEach question row (li)
textStatement text
buttonsYes/No button group
buttonEach option button
checkButtonCheck button
resetButtonReset button
resultResults text

CSS Variables

Scoped under .tbx-yesno:

VariablePurpose
--yesno-icon-colorIcon color (inherits --exercise-layout-icon-color)
--yesno-option-bgOption button background (default)
--yesno-option-bg-selectedOption button background when selected (before validation). Uses color-mix with --exercise-accent-color.
--yesno-option-border-selectedOption button border when selected (before validation). Uses --exercise-accent-color.
--yesno-item-borderRow divider
--yesno-action-bg, --yesno-action-borderCheck/Reset button background and border
--yesno-result-neutral, --yesno-result-correct, --yesno-result-wrongResults text colors (neutral, correct, wrong)
--yesno-correct-bg, --yesno-correct-borderCorrect answer highlight
--yesno-wrong-bg, --yesno-wrong-borderWrong answer highlight

These feed into --exercise-action-bg, --exercise-action-border and --exercise-result-* used by ExerciseLayout.

On this page