Methane@methane-ui/*
CSS LayoutsComponentsSkillsTheme BuilderGitHub
← All Components

<mth-drawing-pad>

@methane-ui/ui~6.8 KB brotli (cold + Lit)~1.4 KB marginal

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

Interactive StageLive Custom Element · <mth-drawing-pad> (@methane-ui/ui)
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>

Properties & Attributes

PropertyAttributeTypeDefaultDescription
tooltool'pen' | 'eraser'"pen"Active drawing mode (pen or eraser).
strokeWidthstroke-widthnumber3Stroke width in pixels.
strokeColorstroke-colorstring""Optional CSS color string for pen strokes.
disableddisabledbooleanfalseDisables canvas drawing and toolbar controls.
labellabelstring""Accessible canvas label.

Events

EventDetail TypeDescription
mth-change{ strokeCount: number }Fired whenever strokes are added, undone, or cleared.

APG Keyboard Matrix

KeyDirectionWhenExpected Behavior
ArrowRightbothDrawing canvas is focusedMoves virtual drawing cursor or extends stroke when pen is active
SpacebothDrawing canvas is focusedStarts or finishes a keyboard drawing stroke at cursor position

Accessibility Checklist

CategoryRequirementVerified By
ariaAll aria-* IDREFs resolve within the same DOM root (ADR-003).scanSameRootAria
focusdelegatesFocus: true with zero host internals.role (ADR-014).lint-plugin & spec-compiler
contrastRenders legible borders, focus outlines, and selection indicators under forced-colors: active.Playwright forced-colors matrix
keyboardImplements all 2 APG keyboard transitions across LTR/RTL.mth-drawing-pad.spec.test.ts
statesExposes ElementInternals CustomStateSet flags: :state(disabled).Conformance suite
i18nRoutes 6 UI/ARIA strings through @methane-ui/core i18n catalog.Locale context test