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

<mth-code-editor>

@methane-ui/code~7.9 KB brotli shell + lazy engine~2.0 KB shell · lazy engine chunk

Form-associated CodeMirror 6 code editor with non-trapping Tab escape toggle, --mth-* theme compartment sync, and hydration-pure lifecycle.

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-code-editor> (@methane-ui/code)
Ready · interact with <mth-code-editor>, or toggle Theme, Direction (LTR/RTL), or props above.

Multi-Framework Playground & Snippets

<script type="module" src="@methane-ui/code/code-editor"></script>
<mth-code-editor language="typescript"></mth-code-editor>

Properties & Attributes

PropertyAttributeTypeDefaultDescription
namenamestring""name property.
labellabelstring""label property.
valuevaluestring""value property.
languagelanguagestring"typescript"language property.
tabTrapsFocustab-traps-focusbooleanfalsetabTrapsFocus property.
requiredrequiredbooleanfalserequired property.
disableddisabledbooleanfalsedisabled property.
readonlyreadonlybooleanfalsereadonly property.

Events

EventDetail TypeDescription
mth-input{ value: string }Emitted event mth-input.
mth-change{ value: string }Emitted event mth-change.

APG Keyboard Matrix

KeyDirectionWhenExpected Behavior
Escapeltreditor surface focused in indent moderestores Tab focus navigation

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 1 APG keyboard transitions across LTR/RTL.mth-code-editor.spec.test.ts
statesExposes ElementInternals CustomStateSet flags: :state(disabled), :state(readonly), :state(invalid), :state(dirty), :state(touched), :state(focused), :state(tab-trap).Conformance suite
i18nRoutes 6 UI/ARIA strings through @methane-ui/core i18n catalog.Locale context test