Skip to content

useAnnotations

Add text annotations at specific price levels and timestamps, with optional colors.

import { useAnnotations } from "react-klinecharts-ui";
const {
annotations,
addAnnotation,
removeAnnotation,
updateAnnotation,
clearAnnotations,
} = useAnnotations();
PropertyTypeDescription
annotationsAnnotation[]All annotations
addAnnotation(text, price, timestamp, color?) => stringAdd annotation; returns ID
removeAnnotation(id: string) => voidRemove by ID
updateAnnotation(id, updates) => voidUpdate text or color
clearAnnotations() => voidRemove all
interface Annotation {
id: string;
text: string;
price: number;
timestamp: number;
color?: string;
}
const { addAnnotation, removeAnnotation } = useAnnotations();
const id = addAnnotation("Earnings", 178.4, Date.parse("2026-01-30"), "#f59e0b");
// later…
removeAnnotation(id);