← All Components
<mth-before-after>
Accessible before/after comparison slider supporting pointer dragging, RTL-aware keyboard scrubbing, and CSP-safe adopted CSSStyleSheet clipping.
When NOT to use: Use a lightweight @methane-ui/css layout class instead of a custom element when static CSS suffices.
Live Interactive Preview
Light Surface · OKLCH 0.96
Dark Surface · OKLCH 0.20
Ready · interact with <mth-before-after>, or toggle Theme, Direction (LTR/RTL), or props above.
Multi-Framework Playground & Snippets
<script type="module" src="@methane-ui/ui/before-after"></script>
<mth-before-after position="50" step="2"></mth-before-after>import '@methane-ui/ui/before-after';
import '@methane-ui/react';
export function Example() {
return <mth-before-after position="50" step="2"></mth-before-after>;
}<script setup lang="ts">
import '@methane-ui/ui/before-after';
</script>
<template>
<mth-before-after position="50" step="2"></mth-before-after>
</template>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import '@methane-ui/ui/before-after';
import { MthBeforeAfterDirective } from '@methane-ui/angular';
@Component({
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [MthBeforeAfterDirective],
template: `<mth-before-after position="50" step="2"></mth-before-after>`,
})
export class ExampleComponent {}<script lang="ts">
import '@methane-ui/ui/before-after';
import MthBeforeAfter from '@methane-ui/svelte/MthBeforeAfter.svelte';
</script>
<MthBeforeAfter position="50" step="2"></MthBeforeAfter>Properties & Attributes
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
position | position | number | 50 | Split divider percentage from 0 to 100. |
step | step | number | 2 | Keyboard arrow increment percentage. |
label | label | string | "" | Accessible region and slider label. |
beforeLabel | before-label | string | "" | Label for the before layer. |
afterLabel | after-label | string | "" | Label for the after layer. |
disabled | disabled | boolean | false | Disables pointer and keyboard adjustment. |
Events
| Event | Detail Type | Description |
|---|---|---|
mth-change | { position: number } | Fired when the comparison split position changes. |
APG Keyboard Matrix
| Key | Direction | When | Expected Behavior |
|---|---|---|---|
| ArrowLeft / ArrowRight | both | comparison slider focused | adjusts split position by step (RTL-aware) |
| PageUp / PageDown | both | comparison slider focused | adjusts split position by large step (10%) |
| Home / End | both | comparison slider focused | jumps split position to 0% or 100% |
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 3 APG keyboard transitions across LTR/RTL. | mth-before-after.spec.test.ts |
| states | Exposes ElementInternals CustomStateSet flags: :state(dragging), :state(disabled). | Conformance suite |
| i18n | Routes 4 UI/ARIA strings through @methane-ui/core i18n catalog. | Locale context test |