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:
Tabto an item,EnterorSpaceto select it, thenEnteron an item in the other set.Escapeclears 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
<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
| Key | Element |
|---|---|
root | Root wrapper |
flow | Scrollable container around the items and connectors |
heading | Heading of each set (see headings); target it per set with [data-set="origin"] / [data-set="target"] |
checkButton | Check button |
resetButton | Reset button |
result | Results text |
CSS Variables
Scoped under .tbx-connectpoints:
| Variable | Purpose |
|---|---|
--connectpoints-heading-color | Set heading text colour (inherits by default) |
--connectpoints-item-bg | Item background (default) |
--connectpoints-item-border | Item border |
--connectpoints-item-connected-bg | Item background when connected (before validation). Uses color-mix with --exercise-accent-color. |
--connectpoints-item-connected-border | Item border when connected (before validation). Uses --exercise-accent-color. |
--connectpoints-item-correct-bg, --connectpoints-item-correct-border | Item when correct (after validation) |
--connectpoints-item-wrong-bg, --connectpoints-item-wrong-border | Item when wrong (after validation) |
--connectpoints-connector | Connector line (default) |
--connectpoints-connector-active | Connector when connected (before validation). Uses --exercise-accent-color. |
--connectpoints-connector-correct | Connector when correct |
--connectpoints-connector-wrong | Connector when wrong |
--connectpoints-point-bg | Handle/point background |
--connectpoints-point-border | Handle/point border |
--connectpoints-point-selected | Handle/point when selected (focus) |
--exercise-action-bg, --exercise-action-border | Check/Reset buttons |
--exercise-result-neutral, --exercise-result-correct, --exercise-result-wrong | Results text |
Item labels use --exercise-layout-content-font-size.
Variants
Columns (default)
Origin and target items are arranged in two columns. Connectors run horizontally.
<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.
<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.
<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.
<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.
<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.
<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"
/>