← All Components
<mth-field>
Layout wrapper and Community Context Protocol provider for Methane form 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-field>, or toggle Theme, Direction (LTR/RTL), or props above.
Multi-Framework Playground & Snippets
<script type="module" src="@methane-ui/ui/field"></script>
<mth-field density="compact">Example</mth-field>import '@methane-ui/ui/field';
import '@methane-ui/react';
export function Example() {
return <mth-field density="compact">Example</mth-field>;
}<script setup lang="ts">
import '@methane-ui/ui/field';
</script>
<template>
<mth-field density="compact">Example</mth-field>
</template>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import '@methane-ui/ui/field';
import { MthFieldDirective } from '@methane-ui/angular';
@Component({
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [MthFieldDirective],
template: `<mth-field density="compact">Example</mth-field>`,
})
export class ExampleComponent {}<script lang="ts">
import '@methane-ui/ui/field';
import MthField from '@methane-ui/svelte/MthField.svelte';
</script>
<MthField density="compact">Example</MthField>Properties & Attributes
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
label | label | string | "" | Field label text propagated to child controls via FieldContext. |
hint | hint | string | "" | Helper description text propagated via FieldContext. |
error | error | string | "" | Validation error message propagated via FieldContext. |
required | required | boolean | false | Marks the field required and propagates via FieldContext. |
disabled | disabled | boolean | false | Disables descendant Methane controls via FieldContext. |
density | density | 'compact' | 'default' | 'comfortable' | "default" | Density scale override for layout spacing. |
Accessibility Checklist
| Category | Requirement | Verified By |
|---|---|---|
| aria | All aria-* IDREFs resolve within the same DOM root (ADR-003). | scanSameRootAria |
| focus | Focus ownership matches focusModel="none". | lint-plugin & spec-compiler |
| contrast | Renders legible borders, focus outlines, and selection indicators under forced-colors: active. | Playwright forced-colors matrix |
| states | Exposes ElementInternals CustomStateSet flags: :state(required), :state(disabled), :state(invalid). | Conformance suite |
| i18n | Routes 1 UI/ARIA strings through @methane-ui/core i18n catalog. | Locale context test |