← All Components
<mth-json-editor>
Form-associated CodeMirror 6 JSON editor with live JSON syntax validation, prettify formatting, collapsible interactive tree view, and --mth-* token synchronization.
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-json-editor>, or toggle Theme, Direction (LTR/RTL), or props above.
Multi-Framework Playground & Snippets
<script type="module" src="@methane-ui/code/json-editor"></script>
<mth-json-editor mode="code"></mth-json-editor>import '@methane-ui/code/json-editor';
import '@methane-ui/react';
export function Example() {
return <mth-json-editor mode="code"></mth-json-editor>;
}<script setup lang="ts">
import '@methane-ui/code/json-editor';
</script>
<template>
<mth-json-editor mode="code"></mth-json-editor>
</template>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import '@methane-ui/code/json-editor';
import { MthJsonEditorDirective } from '@methane-ui/angular';
@Component({
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [MthJsonEditorDirective],
template: `<mth-json-editor mode="code"></mth-json-editor>`,
})
export class ExampleComponent {}<script lang="ts">
import '@methane-ui/code/json-editor';
import MthJsonEditor from '@methane-ui/svelte/MthJsonEditor.svelte';
</script>
<MthJsonEditor mode="code"></MthJsonEditor>Properties & Attributes
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
name | name | string | "" | name property. |
label | label | string | "" | label property. |
value | value | string | "" | value property. |
mode | mode | 'code' | 'tree' | 'split' | "code" | mode property. |
required | required | boolean | false | required property. |
disabled | disabled | boolean | false | disabled property. |
readonly | readonly | boolean | false | readonly property. |
Events
| Event | Detail Type | Description |
|---|---|---|
mth-input | { value: string; valid: boolean } | Emitted event mth-input. |
mth-change | { value: string; valid: boolean } | Emitted event mth-change. |
mth-mode-change | { mode: unknown } | Emitted event mth-mode-change. |
APG Keyboard Matrix
| Key | Direction | When | Expected Behavior |
|---|---|---|---|
| ArrowRight | ltr | toolbar button focused | moves focus to next control |
| ArrowLeft | rtl | toolbar button focused | moves focus to next control |
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-json-editor.spec.test.ts |
| states | Exposes ElementInternals CustomStateSet flags: :state(disabled), :state(readonly), :state(invalid), :state(dirty), :state(touched), :state(focused), :state(split). | Conformance suite |
| i18n | Routes 10 UI/ARIA strings through @methane-ui/core i18n catalog. | Locale context test |