React Hooks
Hooks for accessing annotations, selection, and tools. View Hooks →
Complete API documentation for Annota, supporting both React and Svelte.
Choose your framework to view framework-specific APIs:
React Hooks
Hooks for accessing annotations, selection, and tools. View Hooks →
React Components
React components for building annotation UIs. View Components →
Svelte Stores
Reactive stores for annotations, selection, and tools. View Stores →
Svelte Components
Svelte components for building annotation UIs. View Components →
These APIs are identical for both React and Svelte:
Annotator Instance
Programmatic API for annotation management. View Annotator →
TypeScript Types
Complete type definitions (shared). View Types →
Tools
Built-in annotation tools (PointTool, RectangleTool, etc.). View Tools →
Data Loaders
Load H5, PGM, JSON files (shared). View Loaders →
These types are shared between React and Svelte.
interface Annotation { id: string; shape: Shape; properties?: Record<string, unknown>; style?: AnnotationStyle;}type Shape = | PointShape | RectangleShape | PolygonShape | MultiPolygonShape | CircleShape | LineShape | FreehandShape | PathShape | ImageShape;PointShape:
interface PointShape { type: "point"; point: { x: number; y: number }; bounds: Bounds;}RectangleShape:
interface RectangleShape { type: "rectangle"; x: number; y: number; width: number; height: number; bounds: Bounds;}PolygonShape:
interface PolygonShape { type: "polygon"; points: Array<{ x: number; y: number }>; closed: boolean; bounds: Bounds;}interface AnnotationStyle { fill?: string; fillOpacity?: number; stroke?: string; strokeWidth?: number; strokeOpacity?: number;}interface Layer { id: string; name: string; visible: boolean; opacity?: number; locked?: boolean; filter?: Filter; style?: AnnotationStyle;}Annota includes several annotation tools (shared between frameworks):
import { PointTool, RectangleTool, PolygonTool } from "annota";
const pointTool = new PointTool();const rectangleTool = new RectangleTool();const polygonTool = new PolygonTool();import { PointTool, RectangleTool, PolygonTool } from "annota";
const pointTool = new PointTool();const rectangleTool = new RectangleTool();const polygonTool = new PolygonTool();See the Tools Guide for detailed usage.
import { loadH5Masks, loadH5Coordinates } from "annota";import { loadH5Masks, loadH5Coordinates } from "annota";import { loadJSONFile, exportJSON } from "annota";import { loadJSONFile, exportJSON } from "annota";See the Loaders Guide for more details.
| Hook | Purpose |
|---|---|
useAnnotator() | Access annotator instance |
useAnnotations() | Get all annotations |
useSelection() | Get selected annotations |
useTool() | Activate annotation tool |
useLayers() | Get all layers |
useLayerManager() | Manage layers |
| Store | Purpose |
|---|---|
getAnnotator() | Access annotator instance |
annotations() | Get all annotations |
selection() | Get selected annotations |
tool() | Activate annotation tool |
layers() | Get all layers |
layerManager() | Manage layers |
| Component | React | Svelte |
|---|---|---|
| Provider | AnnotaProvider | AnnotaProvider |
| Viewer | AnnotaViewer | Viewer |
| Annotator | Annotator | Annotator |
| Popup | AnnotationPopup | Popup |
| Context Menu | ContextMenu | ContextMenu |