How it works
A textbook figure of a 2D potential flow. A source of strength Q pushes fluid outward at Q / 2πr and an equal sink pulls it in; the velocity anywhere is the vector sum. The plate (x from −8 to 8 m, y from −4 to 4 m) shows the direction of flow as a grid of small arrows and as streamlines traced from the source. At the probe the source's and the sink's contributions are drawn tip to tail with their sum in ink, and the row under the plate reads the speed, its direction and both contributions. Drag the source, the sink or the probe; a press on the empty plate moves the probe there. Inside half a metre of a source or a sink the speed is capped, a finite core.
Use it for
- Teach potential flow and superposition: let learners see that the velocity at a point is the source's outward push plus the sink's inward pull.
- Show how the streamlines change as the source and the sink move closer, until the pattern approaches a doublet.
Look elsewhere when
- For measured flow data or viscous flow, use a real flow visualisation: this figure is an ideal, inviscid model.
Usage
import React, { useState } from 'react'
import { SourceSinkSampler } from './SourceSinkSampler.jsx'
export function FlowLesson() {
const [points, setPoints] = useState({
source: { x: -4, y: -1 },
sink: { x: 4, y: 1 },
probe: { x: 0, y: 2 },
})
return (
<SourceSinkSampler
value={points}
onChange={(next, { speed }) => setPoints(next)}
strength={20}
labels={{ title: 'A source and a sink' }}
/>
)
}Props
| Prop | Type | Default | What it does |
|---|---|---|---|
value | { source, sink, probe } | — | Controlled positions, each { x, y } in metres, x from −8 to 8 and y from −4 to 4 (rounded to 0.1). |
defaultValue | { source, sink, probe } | { source: { x: -4, y: -1 }, sink: { x: 4, y: 1 }, probe: { x: 0, y: 2 } } | Starting positions when uncontrolled, and what Reset returns to in both modes. |
onChange | (points, reading) => void | — | Called with the new positions and { object ('source', 'sink', 'probe' or null on reset), reason ('drag', 'press', 'tap', 'key', 'cancel' or 'reset'), velocity, speed, angle (degrees, null without flow), source, sink } at the probe, in m/s. |
strength | number | 20 | Strength Q of the source and of the sink in m²/s. Every speed scales with it. |
labels | object | — | Replaces any built-in text: title, caption ('{q}' is the strength), source, sink, probe, velocity, readout ('{point}'), direction ('{angle}'), undefinedDirection, fromSource, fromSink, pointText ('{name}', '{point}'), movable, plate, speedUnit, strengthUnit and reset. |
locale | string | 'en' | Language tag for the decimal numbers. |
className | string | — | Extra class on the card, for example to set its width (30rem by default, never wider than its container). |
Accessibility
- The source, the sink and the probe are each one tab stop, a button with the role description 'movable point' and a name that reads its position. Arrow keys move the focused point by 0.5 m, with Shift by 2 m, clamped to the plate.
- The readout is a polite live region: it reads the position of the probe, the speed, its direction and the two contributions. Reset is a button, marked unavailable while nothing has changed.
- Dragging uses pointer capture. A handle sets touch-action: none, so the page does not scroll while a point is dragged; on the empty plate a tap places the probe and a swipe still scrolls the page. A cancelled gesture puts the point back where it started.
- Colour is not the only key: the source and the sink carry + and − signs, the legend names every colour, and the readout names each contribution.
Motion
After a key press, a tap or Reset, the moved point glides for --ds-duration-fast while the field, streamlines and probe arrows redraw at once; while a point is dragged it follows the pointer directly. With reduced motion every change lands at once.
Add it to your project
Pro members copy a prompt and their coding agent installs the source, the same way as the free components.
SourceSinkSampler.jsxsource-sink-sampler.csstokens.cssREADME.md
Both files install together. The stylesheet reads the design tokens in tokens.css and carries fallbacks, so it also works alone.







