Fine-tune light, shadows, borders, neumorphic
Light and shadows
Borders
Neumorphic
Navigation

BackToTop <pm-back-to-top>

Back to top: a floating button that appears after the page has been scrolled and returns to the top (instantly when the user prefers reduced motion). Focus moves to the top of the page as well.

Full screen

Release notes

Scroll this box. The button appears after 120 px and brings you back up.

2.4

Charts, scheduler and the rich-text editor.

2.3

Tree select, cascader and transfer list.

2.2

Menubar, submenus and hover cards.

2.1

Tour, QR code, virtual list and signature pad.

2.0

Five surface styles and the OKLCH colour engine.

1.9

Native phone patterns: sheets, tab bar and swipe actions.

Props

<script type="module"> import '@prismora/css'; import '@prismora/elements/back-to-top'; </script> <div class="pm-scroll-area pm-card" id="btt-demo" tabindex="0" role="region" aria-label="Release notes" style="--pm-scroll-height: 15rem; inline-size: min(100%, 28rem); padding: var(--pm-space-4)"> <h3 class="pm-text-lg">Release notes</h3> <p class="pm-muted">Scroll this box. The button appears after 120 px and brings you back up.</p> <h4>2.4</h4> <p>Charts, scheduler and the rich-text editor.</p> <h4>2.3</h4> <p>Tree select, cascader and transfer list.</p> <h4>2.2</h4> <p>Menubar, submenus and hover cards.</p> <h4>2.1</h4> <p>Tour, QR code, virtual list and signature pad.</p> <h4>2.0</h4> <p>Five surface styles and the OKLCH colour engine.</p> <h4>1.9</h4> <p>Native phone patterns: sheets, tab bar and swipe actions.</p> <pm-back-to-top target="btt-demo" threshold="120"></pm-back-to-top> </div>

Overview

For a scrolling panel instead of the page, put the element inside the panel and set target to the panel's id: the button then floats in the panel's bottom corner.

Attributes

AttributeTypeDefaultDescription
thresholdnumber600Pixels scrolled before the button appears (default 600).
labelstring—Accessible name (default "Back to top").
position'end' | 'start' | 'center'—Corner: end (default), start or center.
targetstring—Id of a scrolling element to watch and scroll instead of the page.

Also accepts the contextual attributes tone, surface, radius, density, motion, elevation. They are inherited from ancestors' data-* attributes.

Slots

SlotDescription
(default)Custom icon or text.