DocsFramework guides
Get started

Search Subtly documentation

Search by a task, helper name or framework.

Framework guides

React

Client-side effects and refs.

Install

Wrap your application once with InteractionRoot. Use data-ix attributes in JSX.

Terminal
npm install subtly

Initialize

InteractionRoot.jsx

JavaScript
import { useEffect, useRef } from "react";
import { createInteractions } from "subtly";
export function InteractionRoot({ children }) {
const root = useRef(null);
useEffect(() => {
const ix = createInteractions({ root: root.current });
ix.start();
return () => ix.stop();
}, []);
return <div ref={root}>{children}</div>;
}

Use a behavior

HTML
<div data-ix="hover-intent" data-ix-hover-delay="150">
<button type="button">Preview</button>
</div>

Use the shared HTML attributes, or import programmatic helpers inside your framework lifecycle. State and visual rendering stay in your component.

Lifecycle and accessibility

Strict Mode may mount twice in development; cleanup is mandatory. For custom ix:* events attach native listeners with refs rather than assuming React synthetic event support.

Use a single runtime per root; do not overlap roots. Keep native button semantics, focus and click support. For cleanup, call each utility’s returned callback or destroy method.

Try the same behavior

Preview closed. Hover, focus or click to open.

Actual npm package · local demonstrationHover timing needs a desktop pointer

The live example uses native JavaScript; the framework snippets are integration recipes, not separately compiled framework applications.