← All Components
<mth-drawing-pad>
Accessible pointer-capture and keyboard-capable freehand canvas drawing pad with pen, eraser, stroke width, undo, and clear controls.
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-drawing-pad>, or toggle Theme, Direction (LTR/RTL), or props above.
Multi-Framework Playground & Snippets
<script type="module" src="@methane-ui/ui/drawing-pad"></script>
<mth-drawing-pad tool="pen" stroke-width="3"></mth-drawing-pad>import '@methane-ui/ui/drawing-pad';
import '@methane-ui/react';
export function Example() {
return <mth-drawing-pad tool="pen" stroke-width="3"></mth-drawing-pad>;
}<script setup lang="ts">
import '@methane-ui/ui/drawing-pad';
</script>
<template>
<mth-drawing-pad tool="pen" stroke-width="3"></mth-drawing-pad>
</template>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import '@methane-ui/ui/drawing-pad';
import { MthDrawingPadDirective } from '@methane-ui/angular';
@Component({
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [MthDrawingPadDirective],
template: `<mth-drawing-pad tool="pen" stroke-width="3"></mth-drawing-pad>`,
})
export class ExampleComponent {}<script lang="ts">
import '@methane-ui/ui/drawing-pad';
import MthDrawingPad from '@methane-ui/svelte/MthDrawingPad.svelte';
</script>
<MthDrawingPad tool="pen" stroke-width="3"></MthDrawingPad>Properties & Attributes
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
tool | tool | 'pen' | 'eraser' | "pen" | Active drawing mode (pen or eraser). |
strokeWidth | stroke-width | number | 3 | Stroke width in pixels. |
strokeColor | stroke-color | string | "" | Optional CSS color string for pen strokes. |
disabled | disabled | boolean | false | Disables canvas drawing and toolbar controls. |
label | label | string | "" | Accessible canvas label. |
Events
| Event | Detail Type | Description |
|---|---|---|
mth-change | { strokeCount: number } | Fired whenever strokes are added, undone, or cleared. |
APG Keyboard Matrix
| Key | Direction | When | Expected Behavior |
|---|---|---|---|
| ArrowRight | both | Drawing canvas is focused | Moves virtual drawing cursor or extends stroke when pen is active |
| Space | both | Drawing canvas is focused | Starts or finishes a keyboard drawing stroke at cursor position |
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 2 APG keyboard transitions across LTR/RTL. | mth-drawing-pad.spec.test.ts |
| states | Exposes ElementInternals CustomStateSet flags: :state(disabled). | Conformance suite |
| i18n | Routes 6 UI/ARIA strings through @methane-ui/core i18n catalog. | Locale context test |