Leave a comment and start a conversation anywhere on a page
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>
);
}
These can be used to customize the component. You can learn more about customization here.
Note: These variables all apply to the default button used to create new floating threads - not to the threads themselves.
To style the actual thread elements, including the message composer, refer to the Thread CSS variables.
To style the pins which mark where threads have been placed, refer to the Annotations CSS variables.
--cord-floating-threads-font-size:
var(--cord-font-size-body, 14px);
--cord-floating-threads-line-height:
var(--cord-line-height-body, var(--cord-space-l, 20px));
--cord-floating-threads-letter-spacing:
normal;
--cord-floating-threads-text-color:
var(--cord-secondary-button-content-color, var(--cord-color-content-emphasis, #121314));
--cord-floating-threads-text-color--hover:
var(--cord-secondary-button-content-color--hover, var(--cord-color-content-emphasis, #121314));
--cord-floating-threads-text-color--active:
var(--cord-secondary-button-content-color--active, var(--cord-color-base, #FFFFFF));
--cord-floating-threads-text-color--disabled:
var(--cord-secondary-button-content-color--disabled, var(--cord-color-content-secondary, #97979F));
--cord-floating-threads-background-color:
var(--cord-secondary-button-background-color, var(--cord-color-base-strong, #F6F6F6));
--cord-floating-threads-background-color--hover:
var(--cord-secondary-button-background-color--hover, var(--cord-color-base-x-strong, #DADCE0));
--cord-floating-threads-background-color--active:
var(--cord-secondary-button-background-color--active, var(--cord-color-brand-primary, #121314));
--cord-floating-threads-background-color--disabled:
var(--cord-secondary-button-background-color--disabled, var(--cord-color-base-strong, #F6F6F6));
--cord-floating-threads-padding:
6px 8px;
--cord-floating-threads-height:
var(--cord-button-height-auto, auto);
--cord-floating-threads-gap:
var(--cord-space-3xs, 4px);
--cord-floating-threads-border:
var(--cord-button-border-none, none);
--cord-floating-threads-icon-size:
var(--cord-space-l, 20px);
--cord-thread-background-color:
var(--cord-color-base, #FFFFFF);
--cord-thread-border:
1px solid var(--cord-color-base-x-strong, #DADCE0);
--cord-thread-border-top:
var(--cord-thread-border, 1px solid var(--cord-color-base-x-strong, #DADCE0));
--cord-thread-border-right:
var(--cord-thread-border, 1px solid var(--cord-color-base-x-strong, #DADCE0));
--cord-thread-border-bottom:
var(--cord-thread-border, 1px solid var(--cord-color-base-x-strong, #DADCE0));
--cord-thread-border-left:
var(--cord-thread-border, 1px solid var(--cord-color-base-x-strong, #DADCE0));
--cord-thread-border-radius:
var(--cord-border-radius-medium, var(--cord-space-3xs, 4px));
--cord-thread-padding:
0px;
--cord-thread-send-button-font-size:
var(--cord-font-size-body, 14px);
--cord-thread-send-button-text-color:
var(--cord-primary-button-content-color, var(--cord-color-base, #FFFFFF));
--cord-thread-send-button-text-color--hover:
var(--cord-primary-button-content-color--hover, var(--cord-color-base, #FFFFFF));
--cord-thread-send-button-text-color--active:
var(--cord-primary-button-content-color--active, var(--cord-color-base-x-strong, #DADCE0));
--cord-thread-send-button-text-color--disabled:
var(--cord-primary-button-content-color--disabled, var(--cord-color-base, #FFFFFF));
--cord-thread-send-button-background-color:
var(--cord-primary-button-background-color, var(--cord-color-brand-primary, #121314));
--cord-thread-send-button-background-color--hover:
var(--cord-primary-button-background-color--hover, var(--cord-color-brand-primary, #121314));
--cord-thread-send-button-background-color--active:
var(--cord-primary-button-background-color--active, var(--cord-color-brand-primary, #121314));
--cord-thread-send-button-background-color--disabled:
var(--cord-primary-button-background-color--disabled, var(--cord-color-content-secondary, #97979F));
--cord-thread-send-button-padding:
var(--cord-space-2xs, 8px);
--cord-thread-height:
auto;
--cord-thread-max-height:
none;
--cord-thread-width:
auto;