Skip to content

useTactile

Binds motion (GSAP), sound and haptics per interaction phase. Returns { ref, handlers } to spread onto an element. Pointer and keyboard feel identical; motion collapses under prefers-reduced-motion. The same entry exports the physics Echo's own parts move on: createSpring for anything the hand can redirect, useCapPhysics for a cap that presses like Echo's keys, and the liquid cap and morph engine under Morph.

Feel One hook makes a custom control press, spring back and click. For a molded cap that should press like Echo's own keys, with the detent and the clicks on the mechanism, use useCapPhysics.

Preview

Pointer and keyboard feel identical — tab to it and hit Space. Reduced motion collapses the push; the sound follows the provider.

Or let the agent fetch it: get_component("use-tactile") on the Echo MCP server.

Installation

npm install echo-ui-core

This one ships in the echo-ui-core package rather than being copied into your project — npx echo-ui-cli init installs it for you. Import it from echo-ui-core/tactile.

At a glance

Weight
10.9 KB · 37.5 KB with what it imports (minified and gzipped; React not counted)
Needs
gsap
Keyboard
Space and Enter press and release the element the same way a pointer does; a held key doesn't repeat the press.
Reduced motion
Motion follows each token's own collapse; sound follows the SoundProvider, which mutes under reduced motion by default.
Sound
Whatever each phase names — typically press on the way down and release on the way up. Space and Enter play the same as a pointer.

Usage

tsx
import { useTactile } from "echo-ui-core/tactile";

const { ref, handlers } = useTactile<HTMLButtonElement>({
  press: { motion: "press", sound: "press" },
  release: { motion: "pop", sound: "release" },
});
return <button ref={ref} {...handlers}>Record</button>;

Examples

Tactile button

The canonical press/release pairing.

tsx
const { ref, handlers } = useTactile({
  press:   { motion: "press", sound: "press" },
  release: { motion: "pop",   sound: "release" },
});
return <button ref={ref} {...handlers}>Record</button>;

A buzz with the choice

On a phone, a phase can buzz: select's tick comes with its sound; name one for a phase that has no sound.

tsx
useTactile({
  activate: { sound: "select" },
  release:  { haptic: "tick" },
});

Escape hatch

Pass raw GSAP vars / recipe objects instead of token names for full control.

tsx
useTactile({ press: { motion: { rotation: -3, duration: 0.1 } } });

A spring you can redirect

createSpring carries its velocity: sent somewhere else mid-flight, it bends toward the new target instead of starting again from rest. The presets are `springs` in echo-ui-core/motion.

tsx
const x = createSpring(0, springs.snappy, (v) => knob.style.setProperty("--x", `${v}px`));
x.to(120);
// Sent back mid-flight, it keeps its momentum.
x.to(-40);
// Let go of a flick: start from the pointer's speed.
x.to(0, { velocity: 900 });

A cap that presses like Echo's keys

useCapPhysics: it lifts and leans toward the pointer, clicks as it lands on its seam, loads while held and snaps home. HardwareButton is built on it.

tsx
const { ref, handlers } = useCapPhysics<HTMLButtonElement>({ tilt: 4, sound: true });
return <button ref={ref} {...handlers}>Arm</button>;

A spring under reduced motion

createSpring doesn't read the preference; jump with set instead of travelling with to.

tsx
const reduced = useReducedMotion();
if (reduced) x.set(120);
else x.to(120);

Accessibility

  • Keyboard: Space and Enter press and release the element the same way a pointer does; a held key doesn't repeat the press.
  • It adds feel, not semantics: spread its handlers onto a real button (or give the element a role and a name).

Motion & sound

Motion tokens
press, pop
Reduced motion
Motion follows each token's own collapse; sound follows the SoundProvider, which mutes under reduced motion by default.
Sound
Whatever each phase names — typically press on the way down and release on the way up. Space and Enter play the same as a pointer.

Props

useTactile props
PropTypeDefault
pressAs it goes down: on pointer down, or Space or Enter.object
releaseAs it comes back up: on letting go, or when the pointer leaves or focus moves away mid-press.object
hoverWhen a pointer comes over it.object
leaveWhen the pointer leaves it.object
focusWhen it takes focus.object
blurWhen focus leaves it.object
activateWhen it's activated: a click, which a keyboard's Enter or Space also makes.object

Anti-patterns

  • Do not re-implement keyboard handling on top of useTactile — Space/Enter parity is built in.
  • Do not put a smooth material ease on pixel/LCD elements — use motion.glitch (steppy).
  • Do not gate sound on reduced-motion here; the SoundProvider already couples them.
  • Never hand-roll a spring, or a requestAnimationFrame ease, for a part the hand can move or redirect: a tween restarts from rest when retargeted, createSpring keeps its momentum.
  • Never call a spring's to under reduced motion: createSpring doesn't read the preference, so set the value there (useReducedMotion says when).

Changelog

  • v0.3.0 · 2026-10-12 · ChangedEvery item needs echo-ui-core 0.3.0 (all components). The drawn device, readability past AA and the design tests live in core, and the components that use them are built against it, so each item now declares echo-ui-core >=0.3.0 <0.4.0. Update core with the items: npm install echo-ui-core@^0.3.0 (or your package manager's), then npx echo-ui-cli update. An item whose files didn't change is the same code under a new version; the 0.2.0 files stay published.
  • v0.2.0 · 2026-10-04 · ChangedComments only, no behaviour change. Comments in the component source used to cite documents, milestones and ticket numbers from Echo's own planning, none of which exist in your project. The citations are gone and the sentences around them stay. Where a comment was only a citation, it now says what it meant. Three development warnings (HardwareButton's engraved/caption checks and StatusDot's missing-label check) also dropped the ticket code at the end of the message. echo-ui diff will show changes in most items; none of them are to code.
  • v0.2.0 · 2026-10-04 · ChangedAn item's version is now a function of declared data, not of how the changelog is formatted. The version an item ships under is published once and never rewritten, and it used to be inferred from prose: a regex for a bolded "Breaking" run across the whole unreleased section, and attribution by "does a bullet mention this name in backticks". One breaking entry therefore moved every item that changed that cycle, and an entry explaining that "Menu and Sheet are unchanged here" filed itself as a change to Menu and Sheet — which it really had.
  • v0.2.0 · 2026-10-04 · ChangedThe agent brief says Echo has not shipped. llms.txt and the MCP server's instructions led with npx echo-ui-cli init, and that name on npm is a reserved stub with no executable — so a model following the brief wrote an install step that fails with npx's own error. The brief now opens with the caveat, and the docs carry it on every surface that shows a command. One switch (CLI_RELEASED) silences all of them at launch, and a test refuses to let one move without the others. Affects all components only in what the brief says about installing them; no item's props, CSS or rendered semantics change.
  • v0.2.0 · 2026-10-04 · ChangedEcho's home is echo-ui.com. The registry, the docs and the packages all move to it from echo.nawwara.studio. Nothing was published under the old host, so no echo.json anywhere points at it and there is nothing to migrate — this is the last release where that is true.
  • v0.2.0 · 2026-10-04 · ChangedWeights, line heights, letter-spacing, z-index, border widths and icon sizes come from the theme scales in all components, with the old value as a fallback, so components keep working with echo-ui-core@0.0.1. Strays moved to the nearest step: most by under a pixel; HardwareButton icons are 14/16/20px (were 15/17/19).
  • v0.2.0 · 2026-10-04 · FixedContent now reflows into a 320px screen (400% zoom) and survives a doubled browser text size (WCAG 1.4.10, 1.4.4), across all components. Select's 180px floor, NumberField's readout, Segmented and Steps as flex items, EmptyState's grid columns, and Avatar's fixed-pixel disc all gave way; Panel counts its padding inside a width you set (box-sizing: border-box), so a <Panel style={{ width: 220 }}> is now 220px wide overall rather than 260px.