TBX Docs
ExercisesCatalogue

InlineDragAndDrop

Fill-in-the-blank exercises with a drag-and-drop word bank

InlineDragAndDrop is like InlineText and InlineChoices, but blanks are filled by dragging chips from a bank. Choices start shuffled in a pool above the text; drop them into the {0}, {1}, … gaps. Extra strings in choices are distractors. It uses @dnd-kit/react for drag and drop.

Import

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

Example

Drag into Blanks
Drag each word into the correct gap in the text.
Words
were introducedarewasintroducedisare introduced
React a JavaScript library. Hooks in React 16.8.
<InlineDragAndDrop
  entries={[
    {
      text: 'React {0} a JavaScript library. Hooks {1} in React 16.8.',
      choices: ['is', 'are', 'was', 'were introduced', 'are introduced', 'introduced'],
      answers: [['is', 'was'], ['were introduced']],
    },
  ]}
/>

Props

Prop

Type

Labels

Override labels via the labels prop. Supported keys: check, reset (action buttons), results (e.g. "correct" in "3 / 5 correct"), items (bank heading).

<InlineDragAndDrop
  entries={[...]}
  labels={{
    items: 'Word bank',
    check: 'Verify',
    reset: 'Reset',
    results: 'correct',
  }}
/>

Default chrome strings (title, description, info, buttons, bank heading) come from ExerciseMetadata via useExerciseText and follow the book language (EN / RO).

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
bankChoice bank drop zone
bankLabelBank heading
bankContentBank chip area
contentText paragraph(s)
slotInline drop zone
itemDraggable chip
checkButtonCheck button
resetButtonReset button
resultResults text

CSS Variables

Scoped under .tbx-inlinednd:

VariablePurpose
--inlinednd-bank-bg, --inlinednd-bank-borderBank background and border
--inlinednd-bank-dropBank background when drag-over
--inlinednd-slot-border-emptyEmpty blank underline. Uses --exercise-accent-color.
--inlinednd-slot-dropSlot background when drag-over
--inlinednd-item-bg, --inlinednd-item-borderChip background and border
--inlinednd-item-in-slot-bg, --inlinednd-item-in-slot-borderChip in a blank (before validation). Uses --exercise-accent-color.
--inlinednd-item-draggingChip background when dragging
--inlinednd-action-bg, --inlinednd-action-borderCheck/Reset button background and border
--inlinednd-result-neutral, --inlinednd-result-correct, --inlinednd-result-wrongResults text colors
--inlinednd-correct-bg, --inlinednd-correct-borderCorrect chip highlight
--inlinednd-wrong-bg, --inlinednd-wrong-borderWrong chip highlight

These feed into --exercise-action-bg, --exercise-action-border and --exercise-result-* used by ExerciseLayout. Content and chips use --exercise-layout-content-font-size.

Interaction

  • Each blank holds at most one chip. Dropping onto an occupied blank swaps chips.
  • Drag a chip back to the bank to clear a blank.
  • After Check, dragging is disabled and chips show correct/wrong colors. Reset restores the original shuffled bank.

Hook

Scoring uses useFillBlanksExercise, the same hook as InlineText and InlineChoices. Drag-and-drop only sets each blank's answer.

On this page