← All Components
<mth-image-annotator>
Accessible SVG image annotator supporting rectangle, arrow, text, and freehand vector annotations with undo/redo.
When NOT to use: Use a lightweight @methane-ui/css layout class instead of a custom element when static CSS suffices.
Live Interactive Preview
Ready · interact with <mth-image-annotator>, or toggle Theme, Direction (LTR/RTL), or props above.
Multi-Framework Playground & Snippets
<script type="module" src="@methane-ui/media/image-annotator"></script>
<mth-image-annotator tool="rect"></mth-image-annotator>import '@methane-ui/media/image-annotator';
import '@methane-ui/react';
export function Example() {
return <mth-image-annotator tool="rect"></mth-image-annotator>;
}<script setup lang="ts">
import '@methane-ui/media/image-annotator';
</script>
<template>
<mth-image-annotator tool="rect"></mth-image-annotator>
</template>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import '@methane-ui/media/image-annotator';
import { MthImageAnnotatorDirective } from '@methane-ui/angular';
@Component({
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [MthImageAnnotatorDirective],
template: `<mth-image-annotator tool="rect"></mth-image-annotator>`,
})
export class ExampleComponent {}<script lang="ts">
import '@methane-ui/media/image-annotator';
import MthImageAnnotator from '@methane-ui/svelte/MthImageAnnotator.svelte';
</script>
<MthImageAnnotator tool="rect"></MthImageAnnotator>Properties & Attributes
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
src | src | string | "" | Image source URL validated against the safe URL allowlist. |
alt | alt | string | "" | Accessible alternative text for the image. |
tool | tool | 'rect' | 'arrow' | 'text' | 'freehand' | "rect" | Active drawing tool (rect, arrow, text, or freehand). |
disabled | disabled | boolean | false | Disables all toolbar and annotation interactions. |
readonly | readonly | boolean | false | Prevents mutating or adding annotations while allowing inspection. |
label | label | string | "" | Accessible region label. |
annotations | — | readonly unknown[] | — | Vector annotation list rendered over the image. |
Events
| Event | Detail Type | Description |
|---|---|---|
mth-annotation-add | { annotation: unknown } | Fired when a new vector annotation is added. |
mth-annotation-change | { annotations: unknown[] } | Fired when annotations change via add, remove, undo, redo, or clear. |
mth-annotation-select | { id: string | null } | Fired when an annotation item is selected. |
mth-tool-change | { tool: unknown } | Fired when the active drawing tool changes. |
APG Keyboard Matrix
| Key | Direction | When | Expected Behavior |
|---|---|---|---|
| ArrowRight | ltr | Focus is on an annotation list item | Moves focus to the next annotation item |
| ArrowLeft | ltr | Focus is on an annotation list item | Moves focus to the previous annotation item |
| Delete | both | Focus is on an editable annotation item | Removes the focused annotation |
Accessibility Checklist
| Category | Requirement | Verified By |
|---|---|---|
| aria | All aria-* IDREFs resolve within the same DOM root (ADR-003). | scanSameRootAria |
| focus | delegatesFocus: true with zero host internals.role (ADR-014). | lint-plugin & spec-compiler |
| contrast | Renders legible borders, focus outlines, and selection indicators under forced-colors: active. | Playwright forced-colors matrix |
| keyboard | Implements all 3 APG keyboard transitions across LTR/RTL. | mth-image-annotator.spec.test.ts |
| states | Exposes ElementInternals CustomStateSet flags: :state(disabled), :state(readonly). | Conformance suite |
| i18n | Routes 12 UI/ARIA strings through @methane-ui/core i18n catalog. | Locale context test |