← All Components
<mth-query-builder>
Form-associated nested boolean query builder (<mth-query-builder>) with JSON/SQL-style preview and FormControlController validation.
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-query-builder>, or toggle Theme, Direction (LTR/RTL), or props above.
Multi-Framework Playground & Snippets
<script type="module" src="@methane-ui/admin/query-builder"></script>
<mth-query-builder value="{"combinator":"and","items":[]}" show-preview></mth-query-builder>import '@methane-ui/admin/query-builder';
import '@methane-ui/react';
export function Example() {
return <mth-query-builder value="{"combinator":"and","items":[]}" show-preview></mth-query-builder>;
}<script setup lang="ts">
import '@methane-ui/admin/query-builder';
</script>
<template>
<mth-query-builder value="{"combinator":"and","items":[]}" show-preview></mth-query-builder>
</template>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import '@methane-ui/admin/query-builder';
import { MthQueryBuilderDirective } from '@methane-ui/angular';
@Component({
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [MthQueryBuilderDirective],
template: `<mth-query-builder value="{"combinator":"and","items":[]}" show-preview></mth-query-builder>`,
})
export class ExampleComponent {}<script lang="ts">
import '@methane-ui/admin/query-builder';
import MthQueryBuilder from '@methane-ui/svelte/MthQueryBuilder.svelte';
</script>
<MthQueryBuilder value="{"combinator":"and","items":[]}" show-preview></MthQueryBuilder>Properties & Attributes
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
name | name | string | "" | Form field name for FormData submission. |
value | value | string | "{\"combinator\":\"and\",\"items\":[]}" | Serialized JSON string of the query AST. |
fields | — | ReadonlyArray<unknown> | — | Available field definitions. |
showPreview | show-preview | boolean | true | Displays serialized JSON query preview. |
disabled | disabled | boolean | false | Disables all query controls. |
required | required | boolean | false | Requires at least one leaf rule. |
readonly | readonly | boolean | false | Prevents edits while allowing inspection. |
error | error | string | "" | Explicit error message. |
Events
| Event | Detail Type | Description |
|---|---|---|
mth-change | { value: string; query: unknown } | Emitted when the nested query structure changes. |
APG Keyboard Matrix
| Key | Direction | When | Expected Behavior |
|---|---|---|---|
| Enter | both | focus is on group/rule controls | adds or updates query structure |
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 1 APG keyboard transitions across LTR/RTL. | mth-query-builder.spec.test.ts |
| states | Exposes ElementInternals CustomStateSet flags: :state(disabled), :state(readonly), :state(invalid), :state(dirty), :state(touched). | Conformance suite |
| i18n | Routes 18 UI/ARIA strings through @methane-ui/core i18n catalog. | Locale context test |