Skip to content

Scroll Anchor

Infrastructure component

<loquix-scroll-anchor> is the small floating button that appears once the reader has scrolled away from the bottom of a conversation. It renders the button and reports the click; the scrolling itself belongs to whatever owns the list.

The host is positioned absolute against bottom and right, so it anchors to the nearest positioned ancestor. Give your scroll container position: relative, or the button drifts to whatever ancestor happens to be positioned.

loquix-scroll-anchorvisibility is controlledreports, does not scroll
Visible state Live component

Shown with visible set. Without it the button fades out and stops receiving clicks; because the host is absolutely positioned it never takes part in layout either way.

import '@loquix/core/define/define-scroll-anchor';
<loquix-scroll-anchor visible label="Jump to newest message"></loquix-scroll-anchor>
const anchor = document.querySelector('loquix-scroll-anchor');
anchor.addEventListener('loquix-scroll-anchor-click', () => {
list.scrollTo({ top: list.scrollHeight, behavior: 'smooth' });
});
Property Attribute Type Default Description
visible visible boolean false Whether the button is shown. Controlled by the parent.
label label string localized Accessible label for the button.
Event Detail Description
loquix-scroll-anchor-click — Fired when the button is clicked.
Part Purpose
button The button element.
Variable Purpose
--loquix-scroll-anchor-icon Custom icon as a mask-image URL. Monochrome — it inherits the button color.
--loquix-scroll-anchor-icon-size Icon size.
--loquix-scroll-anchor-size Button size.
--loquix-scroll-anchor-bg Button background.
--loquix-scroll-anchor-color Icon color.
--loquix-scroll-anchor-shadow Button shadow.
--loquix-scroll-anchor-border-radius Button border radius.
--loquix-scroll-anchor-bottom Distance from the bottom.
--loquix-scroll-anchor-right Distance from the right.