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

<mth-conditional-field>

@methane-ui/ui~7.9 KB brotli (cold + Lit)~2.0 KB marginal

FormContext-reactive conditional container that shows/hides or disables descendant form controls based on form state, field predicates, or attribute rules.

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

Multi-Framework Playground & Snippets

<script type="module" src="@methane-ui/ui/conditional-field"></script>
<mth-conditional-field operator="eq" mode="hide"></mth-conditional-field>

Properties & Attributes

PropertyAttributeTypeDefaultDescription
fieldfieldstring""Target form control name within the owning form or values map.
equalsequalsstring""Expected comparison value (or comma-separated values for operator="in").
operatoroperator'eq' | 'neq' | 'truthy' | 'empty' | 'in'"eq"Comparison operator (eq | neq | truthy | empty | in).
modemode'hide' | 'disable'"hide"When condition fails, either hides (hide) or keeps visible and disables descendants via FORM_CONTEXT (disable).
disableWhenHiddendisable-when-hiddenbooleantrueAutomatically propagates FORM_CONTEXT.disabled = true while hidden.

Events

EventDetail TypeDescription
mth-condition-change{ matched: boolean }Fired when evaluated condition match state transitions.

Accessibility Checklist

CategoryRequirementVerified By
ariaAll aria-* IDREFs resolve within the same DOM root (ADR-003).scanSameRootAria
focusFocus ownership matches focusModel="none".lint-plugin & spec-compiler
contrastRenders legible borders, focus outlines, and selection indicators under forced-colors: active.Playwright forced-colors matrix
statesExposes ElementInternals CustomStateSet flags: :state(matched), :state(hidden-branch).Conformance suite
i18nRoutes 1 UI/ARIA strings through @methane-ui/core i18n catalog.Locale context test