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

<mth-back-to-top>

@methane-ui/ui~6.8 KB brotli (cold + Lit)~1.4 KB marginal

Floating scroll-to-top action button that reveals automatically after scrolling past threshold pixels.

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-back-to-top> (@methane-ui/ui)
Ready · interact with <mth-back-to-top>, or toggle Theme, Direction (LTR/RTL), or props above.

Multi-Framework Playground & Snippets

<script type="module" src="@methane-ui/ui/back-to-top"></script>
<mth-back-to-top threshold="300" smooth>Example</mth-back-to-top>

Properties & Attributes

PropertyAttributeTypeDefaultDescription
thresholdthresholdnumber300Vertical scroll offset in pixels before the button becomes visible.
labellabelstring""Accessible button aria-label override.
smoothsmoothbooleantrueUses smooth scroll behavior unless reduced motion is preferred.
visiblevisiblebooleanfalseReflected visibility state when threshold is exceeded or alwaysVisible is true.
alwaysVisiblealways-visiblebooleanfalseKeeps the button visible regardless of scroll offset.

Events

EventDetail TypeDescription
mth-scroll-top{ threshold: number }Cancelable event dispatched just before scrolling to top.

APG Keyboard Matrix

KeyDirectionWhenExpected Behavior
Enterbothbutton focusedscrolls document or target container to top
Spacebothbutton focusedscrolls document or target container to top

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 2 APG keyboard transitions across LTR/RTL.mth-back-to-top.spec.test.ts
statesExposes ElementInternals CustomStateSet flags: :state(visible).Conformance suite
i18nRoutes 2 UI/ARIA strings through @methane-ui/core i18n catalog.Locale context test