Scroll Indicator
A thin bar along the top or bottom edge that fills as you scroll the page or a container.
<arc-scroll-indicator>Overview
ScrollIndicator shows how far the reader has scrolled. The bar fills left to right. It tracks the window by default, or the element matched by the target selector. A selector that matches nothing falls back to the window. Its scroll listener updates the bar at most once per animation frame.
The bar uses position: sticky on the top edge, or the bottom with position="bottom", and has pointer-events: none, so it never blocks clicks or text selection. color="accent" fills it with --accent-primary, and color="gradient" blends primary to secondary. size sets the thickness: sm 2px (the default), md 3px or lg 4px.
The bar is a role="progressbar" labelled "Scroll progress", with aria-valuenow from 0 to 100.
Guidelines
Do
- Set `target` when the scrolling happens in a panel, not the page
Don't
- Don't add it to short pages that barely scroll
- Don't put more than one on the same scroll container
- Don't use it for loading. Use Progress
Features
- Parts: `base`, `bar` and `fill`
Preview
Scroll this container to see the indicator fill...
Usage
This component needs JavaScript. Use the Web Component or a framework wrapper.
<!-- Page-level scroll indicator -->
<arc-scroll-indicator></arc-scroll-indicator>
<!-- Gradient bar tracking a specific container -->
<arc-scroll-indicator target="#my-panel" color="gradient" size="md"></arc-scroll-indicator>import { ScrollIndicator } from '@arclux/arc-ui-react';
{/* Page-level */}
<ScrollIndicator />
{/* Target a container */}
<ScrollIndicator target="#my-panel" color="gradient" size="md" /><script setup>
import { ScrollIndicator } from '@arclux/arc-ui-vue';
</script>
<template>
<ScrollIndicator />
<ScrollIndicator target="#my-panel" color="gradient" size="md" />
</template><script>
import { ScrollIndicator } from '@arclux/arc-ui-svelte';
</script>
<ScrollIndicator />
<ScrollIndicator target="#my-panel" color="gradient" size="md" />import { Component } from '@angular/core';
import { ScrollIndicator } from '@arclux/arc-ui-angular';
@Component({
imports: [ScrollIndicator],
template: `
<arc-scroll-indicator />
<arc-scroll-indicator target="#my-panel" color="gradient" size="md" />
`,
})
export class ArticlePage {}import { ScrollIndicator } from '@arclux/arc-ui-solid';
export default function Example() {
return (
<>
<ScrollIndicator />
<ScrollIndicator target="#my-panel" color="gradient" size="md" />
</>
);
}import { ScrollIndicator } from '@arclux/arc-ui-preact';
export default function Example() {
return (
<>
<ScrollIndicator />
<ScrollIndicator target="#my-panel" color="gradient" size="md" />
</>
);
}API
targetstring''- CSS selector for the scroll container to track. Defaults to the window when empty.
position'top' | 'bottom''top'- Which edge the indicator sticks to.
size'sm' | 'md' | 'lg''sm'- Bar thickness: sm (2px), md (3px), lg (4px).
color'accent' | 'gradient''accent'- Fill color mode. Accent uses
--accent-primary. Gradient blends from primary to secondary.
See also
- ProgressA progress bar or spinner for long-running work, with or without a known percentage.
- Scroll SpyAn "On this page" table of contents that highlights the section you're reading.
- Scroll AreaA container that scrolls its content in one or both directions, with a thin scrollbar in the theme's colors.