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

<mth-before-after>

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

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

Interactive StageLive Custom Element · <mth-before-after> (@methane-ui/ui)
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>

Properties & Attributes

PropertyAttributeTypeDefaultDescription
positionpositionnumber50Split divider percentage from 0 to 100.
stepstepnumber2Keyboard arrow increment percentage.
labellabelstring""Accessible region and slider label.
beforeLabelbefore-labelstring""Label for the before layer.
afterLabelafter-labelstring""Label for the after layer.
disableddisabledbooleanfalseDisables pointer and keyboard adjustment.

Events

EventDetail TypeDescription
mth-change{ position: number }Fired when the comparison split position changes.

APG Keyboard Matrix

KeyDirectionWhenExpected Behavior
ArrowLeft / ArrowRightbothcomparison slider focusedadjusts split position by step (RTL-aware)
PageUp / PageDownbothcomparison slider focusedadjusts split position by large step (10%)
Home / Endbothcomparison slider focusedjumps split position to 0% or 100%

Accessibility Checklist

CategoryRequirementVerified By
ariaAll aria-* IDREFs resolve within the same DOM root (ADR-003).scanSameRootAria
focusdelegatesFocus: true with zero host internals.role (ADR-014).lint-plugin & spec-compiler
contrastRenders legible borders, focus outlines, and selection indicators under forced-colors: active.Playwright forced-colors matrix
keyboardImplements all 3 APG keyboard transitions across LTR/RTL.mth-before-after.spec.test.ts
statesExposes ElementInternals CustomStateSet flags: :state(dragging), :state(disabled).Conformance suite
i18nRoutes 4 UI/ARIA strings through @methane-ui/core i18n catalog.Locale context test