← All Components
<mth-segmented-control>
Form-associated single-select segmented control with animated RTL-safe active indicator pill, roving focus, and slotted or options-driven items.
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-segmented-control>, or toggle Theme, Direction (LTR/RTL), or props above.
Multi-Framework Playground & Snippets
<script type="module" src="@methane-ui/ui/segmented-control"></script>
<mth-segmented-control size="sm">Example</mth-segmented-control>import '@methane-ui/ui/segmented-control';
import '@methane-ui/react';
export function Example() {
return <mth-segmented-control size="sm">Example</mth-segmented-control>;
}<script setup lang="ts">
import '@methane-ui/ui/segmented-control';
</script>
<template>
<mth-segmented-control size="sm">Example</mth-segmented-control>
</template>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import '@methane-ui/ui/segmented-control';
import { MthSegmentedControlDirective } from '@methane-ui/angular';
@Component({
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [MthSegmentedControlDirective],
template: `<mth-segmented-control size="sm">Example</mth-segmented-control>`,
})
export class ExampleComponent {}<script lang="ts">
import '@methane-ui/ui/segmented-control';
import MthSegmentedControl from '@methane-ui/svelte/MthSegmentedControl.svelte';
</script>
<MthSegmentedControl size="sm">Example</MthSegmentedControl>Properties & Attributes
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
name | name | string | "" | Form field name. |
value | value | string | "" | Selected segment value. |
defaultValue | default-value | string | "" | Initial value restored on form reset. |
label | label | string | "" | Group label. |
hint | hint | string | "" | Helper message. |
error | error | string | "" | Validation error message. |
size | size | 'sm' | 'md' | 'lg' | "md" | Control size variant. |
fullWidth | full-width | boolean | false | Expands control to full container width. |
disabled | disabled | boolean | false | Disables the segmented control. |
required | required | boolean | false | Marks selection required. |
options | — | ReadonlyArray<unknown> | null | null | Programmatic array of segmented options. |
Events
| Event | Detail Type | Description |
|---|---|---|
mth-change | { value: string } | Dispatched when the user selects a segment. |
APG Keyboard Matrix
| Key | Direction | When | Expected Behavior |
|---|---|---|---|
| ArrowRight | ltr | segment focused | moves focus to next segment |
| ArrowLeft | rtl | segment focused | moves focus to next segment in RTL |
| Home / End | both | segment focused | moves focus to first or last enabled segment |
| Enter / Space | both | segment focused | selects the focused segment |
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 4 APG keyboard transitions across LTR/RTL. | mth-segmented-control.spec.test.ts |
| states | Exposes ElementInternals CustomStateSet flags: :state(dirty), :state(touched), :state(user-invalid), :state(disabled), :state(required). | Conformance suite |
| i18n | Routes 2 UI/ARIA strings through @methane-ui/core i18n catalog. | Locale context test |