Leave a comment and start a conversation anywhere on a page
To display annotations on a page, we strongly recommend using Cord Pins and Cord Threads.
Click the button above to enter annotation mode.
Then click anywhere on the page!
The Floating Threads
component allows you to leave a comment anywhere on the page. Think of it like the comment mode in Figma, for example. It not only provides you with a button to start commenting, but also renders all of your existing threads on that page.
This component renders a single button. Clicking on it will enter the comment mode, which allows users to click anywhere on the page to add a comment which will stick to that particular element on the page. After clicking, a composer will appear right next to where the user clicked, allowing them type a message. You can retrieve and reply to an existing comment by clicking on the pins on the page.
For the best experience with Floating Threads
, we recommend using the Annotations API. This ensures that your users' messages appear in the right place, even if other things change on the page. Without using this API, you may find that pins disappear.
This component pairs well with:
import { FloatingThreads } from "@cord-sdk/react";
export const Example = () => {
return (
<FloatingThreads location={{ "page": "index" }} />
);
};
Add comment
.document.title
) will be used as a default value.false
.<FloatingThreads />
component
can be used to programmatically open a particular thread.<cord-floating-threads>
DOM element:import { useCallback, useRef } from "react";
import {
CordProvider,
FloatingThreads,
ThreadList,
} from "@cord-sdk/react";
const App = () => {
const floatingThreadsRef = useRef(null);
const onThreadClickCallback = useCallback(
(threadID: string, threadSummary: ThreadSummary) => {
if (!floatingThreadsRef.current) {
return;
}
floatingThreadsRef.current.openThread(threadID);
},
[]
);
return (
<CordProvider clientAuthToken={cordToken}>
<ThreadList location={{ page: 'foo' }} onThreadClick={onThreadClickCallback} />
<FloatingThreads location={{ page: 'foo'}} ref={floatingThreadsRef}>
</CordProvider>
);
}