TBX Docs
ExercisesCatalogue

PickOne

Single-choice questions with buttons, radio, or dropdown

PickOne presents one question per row with a set of choices. Only one answer is correct. Renders as buttons (default), radio group, or dropdown based on variant.

Import

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

Example

Pick One
Choose the correct answer from the given options.
  • What is the capital of France?
  • Which planet is closest to the Sun?
<PickOne
  entries={[
    {
      text: 'What is the capital of France?',
      choices: [
        { value: 'london', label: 'London' },
        { value: 'paris', label: 'Paris' },
        { value: 'berlin', label: 'Berlin' },
      ],
      answer: 'paris',
    },
    {
      text: 'Which planet is closest to the Sun?',
      choices: [
        { value: 'venus', label: 'Venus' },
        { value: 'mercury', label: 'Mercury' },
        { value: 'mars', label: 'Mars' },
      ],
      answer: 'mercury',
    },
  ]}
/>

Props

Prop

Type

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)
textQuestion text
optionsOptions container
optionEach option button
triggerDropdown trigger (variant="dropdown")
dropdownDropdown panel
checkButtonCheck button
resetButtonReset button
resultResults text

CSS Variables

Scoped under .tbx-pickone:

VariablePurpose
--pickone-option-bgOption button background (default)
--pickone-option-bg-selectedOption button background when selected (before validation). Uses color-mix with --exercise-accent-color.
--pickone-option-border-selectedOption button border when selected (before validation). Uses --exercise-accent-color.
--pickone-item-borderRow divider
--pickone-action-bg, --pickone-action-borderCheck/Reset button background and border
--pickone-result-neutral, --pickone-result-correct, --pickone-result-wrongResults text colors (neutral, correct, wrong)
--pickone-correct-bg, --pickone-correct-borderCorrect answer highlight
--pickone-wrong-bg, --pickone-wrong-borderWrong answer highlight
--pickone-dropdown-bg, --pickone-dropdown-border, --pickone-dropdown-shadowDropdown panel (variant="dropdown")

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

Content and option buttons inherit --exercise-layout-content-font-size from ExerciseLayout.

Labels

Override labels via the labels prop. Supported keys: check, reset (action buttons), results (e.g. "correct" in "3 / 5 correct"), select (dropdown trigger text when no choice selected, e.g. "Select...").

<PickOne
  entries={[...]}
  labels={{
    check: 'Verify',
    reset: 'Try again',
    results: 'correct',
    select: 'Choose...',
  }}
/>

Variants

Buttons (default)

Pick One
Choose the correct answer from the given options.
  • What is the capital of France?
<PickOne
  entries={[
    {
      text: 'What is the capital of France?',
      choices: [
        { value: 'london', label: 'London' },
        { value: 'paris', label: 'Paris' },
        { value: 'berlin', label: 'Berlin' },
      ],
      answer: 'paris',
    },
  ]}
  variant="buttons"
/>

Radio

Pick One
Choose the correct answer from the given options.
  • What is the capital of France?
<PickOne
  entries={[
    {
      text: 'What is the capital of France?',
      choices: [
        { value: 'london', label: 'London' },
        { value: 'paris', label: 'Paris' },
        { value: 'berlin', label: 'Berlin' },
      ],
      answer: 'paris',
    },
  ]}
  variant="radio"
/>
Pick One
Choose the correct answer from the given options.
  • What is the capital of France?
<PickOne
  entries={[
    {
      text: 'What is the capital of France?',
      choices: [
        { value: 'london', label: 'London' },
        { value: 'paris', label: 'Paris' },
        { value: 'berlin', label: 'Berlin' },
      ],
      answer: 'paris',
    },
  ]}
  variant="dropdown"
/>

On this page