Reference

BackToTop

A button that appears once the page has scrolled past after: px, and takes the reader — and the focus — back to the top.

BackToTop(label: String, after: Number)

Since 6.2.0

No preview for this one: the example below shows how it is written.

Example

wf

Stack(gap: .md) { for n in 1..=12 { Text("Chapter {n}: what the page says, long enough to scroll past.") } } BackToTop(after: 600, label: "Back to the top")

At its default

wf

Text("A long page of release notes.") BackToTop

Props

Props of BackToTop
PropTypeUnsetMeaning

label:

String

Back to top

Its accessible name and tooltip (aria-label, title); the button shows only an upward chevron

after:

Number

400

How far the window must scroll down before it appears, in px; 0 counts as 400

Attribute families: global, aria, data. Plus the 22 universal props every element takes: animate:, exit:, speed:, duration:, delay:, easing:, stagger:, on:, count:, shared:, class:, ref:, drag:, dragGroup:, dropValue:, dropAxis:, dropInside:, roving:, trapFocus:, mount:, update:, cleanup:.

Flags and cases

A flag is written after the parentheses with a dot: a Bool prop, or a case of one of the element's enum props. A case the enum lacks is an error with a hint.

No flags of its own.

Events

Every element also takes the props, the events and the attribute families listed on every element.

Slots

It takes no slots.

Renders with the class wf-back-to-top, stable across releases, so a stylesheet may target it.

These controls list the props' cases; the example below shows them written.