TBX Docs
ExercisesCatalogue

ConnectPoints

Match pairs by drawing connectors between origin and target items

ConnectPoints lets users match items between the origin set and the target set by drawing connectors, in two lists or two clouds of items. Items wrap and shrink to fit the available width, and connectors always meet the points they join, including on zoomed pages and inside modals.

Interaction

Connections can start from either set:

  • Tap or click an item, then an item in the other set. This works without dragging, so it stays usable on small screens and long lists.
  • Drag from one item to an item in the other set. The page scrolls automatically when the pointer nears an edge. On touch screens, drag from the item's point; swiping the rest of the item scrolls the page.
  • Keyboard: Tab to an item, Enter or Space to select it, then Enter on an item in the other set. Escape clears the selection.

Each item holds one connection. Connecting an item that already has one replaces it. To remove a connection, click its connector, or focus either item and press Delete.

Import

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

Example

Connect Points
Draw connections between matching items.
Paris
Berlin
Madrid
France
Germany
Spain
<ConnectPoints
  pairs={[
    { origin: 'Paris', target: 'France' },
    { origin: 'Berlin', target: 'Germany' },
    { origin: 'Madrid', target: 'Spain' },
  ]}
  layout="columns"
/>

Props

Prop

Type

Labels

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

<ConnectPoints
  pairs={[{ origin: 'Paris', target: 'France' }]}
  labels={{
    check: 'Check answers',
    reset: 'Reset',
    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
flowScrollable container around the items and connectors
headingHeading of each set (see headings); target it per set with [data-set="origin"] / [data-set="target"]
checkButtonCheck button
resetButtonReset button
resultResults text

CSS Variables

Scoped under .tbx-connectpoints:

VariablePurpose
--connectpoints-heading-colorSet heading text colour (inherits by default)
--connectpoints-item-bgItem background (default)
--connectpoints-item-borderItem border
--connectpoints-item-connected-bgItem background when connected (before validation). Uses color-mix with --exercise-accent-color.
--connectpoints-item-connected-borderItem border when connected (before validation). Uses --exercise-accent-color.
--connectpoints-item-correct-bg, --connectpoints-item-correct-borderItem when correct (after validation)
--connectpoints-item-wrong-bg, --connectpoints-item-wrong-borderItem when wrong (after validation)
--connectpoints-connectorConnector line (default)
--connectpoints-connector-activeConnector when connected (before validation). Uses --exercise-accent-color.
--connectpoints-connector-correctConnector when correct
--connectpoints-connector-wrongConnector when wrong
--connectpoints-point-bgHandle/point background
--connectpoints-point-borderHandle/point border
--connectpoints-point-selectedHandle/point when selected (focus)
--exercise-action-bg, --exercise-action-borderCheck/Reset buttons
--exercise-result-neutral, --exercise-result-correct, --exercise-result-wrongResults text

Item labels use --exercise-layout-content-font-size.

Variants

Columns (default)

Origin and target items are arranged in two columns. Connectors run horizontally.

Connect Points
Draw connections between matching items.
Paris
Berlin
Madrid
France
Germany
Spain
<ConnectPoints
  pairs={[
    { origin: 'Paris', target: 'France' },
    { origin: 'Berlin', target: 'Germany' },
    { origin: 'Madrid', target: 'Spain' },
  ]}
  layout="columns"
/>

Rows

Origin items on top, target items below. Connectors run vertically. Use with isRandom to shuffle the target set order.

Connect Points
Draw connections between matching items.
A
B
C
1
2
3
<ConnectPoints
  pairs={[
    { origin: 'A', target: '1' },
    { origin: 'B', target: '2' },
    { origin: 'C', target: '3' },
  ]}
  layout="rows"
  isRandom
/>

Cloud

Each set wraps into a compact group of chips, with origins above targets. Use it for larger sets, or wherever two long lists would not fit the screen. Connectors pass behind the items and are faded; the connector of the item you hover, select or drag is emphasised so it stays easy to follow. Combine it with isRandom, otherwise both groups appear in the same order.

Connect Points
Draw connections between matching items.
Paris
Berlin
Madrid
Rome
Lisbon
Vienna
Athens
Warsaw
Dublin
Oslo
Prague
Helsinki
France
Germany
Spain
Italy
Portugal
Austria
Greece
Poland
Ireland
Norway
Czechia
Finland
<ConnectPoints
  pairs={[
      { origin: "Paris", target: "France" },
      { origin: "Berlin", target: "Germany" },
      { origin: "Madrid", target: "Spain" },
      { origin: "Rome", target: "Italy" },
      { origin: "Lisbon", target: "Portugal" },
      { origin: "Vienna", target: "Austria" },
      { origin: "Athens", target: "Greece" },
      { origin: "Warsaw", target: "Poland" },
      { origin: "Dublin", target: "Ireland" },
      { origin: "Oslo", target: "Norway" },
      { origin: "Prague", target: "Czechia" },
      { origin: "Helsinki", target: "Finland" },
    ]}
  layout="cloud"
  isRandom
/>

Randomised origins

Pass isRandom="origin" to shuffle the origin set while targets stay in definition order. Use isRandom="both" to shuffle both sets.

Connect Points
Draw connections between matching items.
Paris
Berlin
Madrid
Rome
France
Germany
Spain
Italy
<ConnectPoints
  pairs={[
    { origin: 'Paris', target: 'France' },
    { origin: 'Berlin', target: 'Germany' },
    { origin: 'Madrid', target: 'Spain' },
    { origin: 'Rome', target: 'Italy' },
  ]}
  layout="columns"
  isRandom="origin"
/>

Headings

Use headings to label each set. In columns they sit above each column, in rows at the start of each row, and in cloud above the origins and below the targets.

Connect Points
Draw connections between matching items.
Capital
Paris
Berlin
Madrid
Country
France
Germany
Spain
<ConnectPoints
  headings={{ origin: 'Capital', target: 'Country' }}
  pairs={[
    { origin: 'Paris', target: 'France' },
    { origin: 'Berlin', target: 'Germany' },
    { origin: 'Madrid', target: 'Spain' },
  ]}
  isRandom
/>

Distractors

Leave out origin or target in a pair (or set it to null) to add an item with no partner. Distractors must stay unconnected, so one set can hold more items than the other and the last match cannot be found by elimination. They are shuffled with their set like any other item.

The result counts the real pairs found. Connecting a distractor makes the answer wrong and adds that connection to the total, so "3 / 4 correct" means three pairs were right and one connection should not have been made.

Connect Points
Draw connections between matching items.
Capital
Paris
Berlin
Madrid
Rome
Lyon
Hamburg
Country
France
Germany
Spain
Italy
<ConnectPoints
  headings={{ origin: 'Capital', target: 'Country' }}
  pairs={[
    { origin: 'Paris', target: 'France' },
    { origin: 'Berlin', target: 'Germany' },
    { origin: 'Madrid', target: 'Spain' },
    { origin: 'Rome', target: 'Italy' },
    { origin: 'Lyon' },     // no country: must stay unconnected
    { origin: 'Hamburg' },
  ]}
  isRandom="both"
/>

On this page