Toggle Sidebar B
AppearanceLight & dark mode D

Dodge Field

Playful field whose child darts away from the pointer, glides back home when you leave, and finally gives in after a few dodges.

Default

Move the pointer toward the pill. After a few dodges it gives in and lets you click it. Nothing dodges on touch devices.

Dark previewReplay previewOpen in new tab

Customize

Ink
Contrast
Field Height240px
Reach72px
Radius120px
Falloff2
Flee130ms
Return620ms
Return Bounce0.1
Patience4
Axis
Wall

API Reference

DodgeField

PropTypeDefaultDescription
tauntsstring[]['Catch me', 'Nope', 'Too slow', 'Almost', 'Okay, okay']Labels for the built-in pill: the first at rest, then one per dodge, the last once it relents.
noticestring''One line shown under the child on touch devices, where nothing dodges.
inkColorstring'#f5f5f5'The pill tint and text, the caught fill and the focus ring all derive from it.
contrastColorstring'#18181b'Text colour while the pill is caught.
fieldHeightnumber240Height of the invisible field in pixels. Its width is the container.
reachnumber72How far it bolts, in pixels, with the pointer on its home.
radiusnumber120Distance from home at which it starts to react, in pixels.
falloffnumber2Exponent of the reaction curve. 1 drifts away from far off, 4 only flinches at the last moment.
fleeDurationnumber130Settle time of the dart, in milliseconds.
returnDurationnumber620Settle time of the glide home, in milliseconds.
returnBouncenumber0.1Overshoot on the way home. 0.1 is a hair, 0.3 a visible wobble.
axis'both' | 'x' | 'y''both'Which way it may flee.
wall'clamp' | 'bounce''clamp'At the edge of the field: stop dead, or fold the overflow back so it rebounds.
patiencenumber4Dodges before it gives in and sits still, at least 1. Never wrap a decline or close control in a field that dodges.
disabledbooleanfalseSits still and stops counting. The child stays clickable.
EventDescription
dodgeEmitted on each counted dodge with the running count.
relentEmitted when it gives in.
catchEmitted when the child is clicked.
SlotDescription
defaultWhat flees, as a scoped slot receiving dodges, gave, caught and fleeing. Omit it for the built-in pill.

Accessibility

Keyboard shortcuts and ARIA behavior.

  • The built-in pill is a real button labelled with the first taunt, and the taunt text is hidden from assistive technology. It stays focusable and clickable by keyboard.
  • Nothing dodges on touch devices, with prefers-reduced-motion or when disabled.
  • Never wrap a decline or close control in a field that dodges.