Playground

Scroll progress

A thin bar fixed to the top of the window that fills as the page scrolls.

  • Built on native elements
  • Decorative and aria-hidden by default.
  • With `label` it is a progressbar with aria-valuenow from 0 to 100, updated as the page scrolls.
  • No transition, so there is no motion beyond the scroll itself.
  • Styles in one file: scroll-progress.css

Import

import '@monoline/css';
import {ScrollProgress} from '@monoline/react';

Not installed yet? Pick a route.

Copies the source and its styles into your project.

npx monoline add scroll-progress

Usage

import {ScrollProgress} from '@monoline/react';

<ScrollProgress />

Examples

Page progress

Fixed to the top of the window; scroll this page to see it fill.

Named for assistive tech

Pass `label` to expose it as a progressbar.

Props

ScrollProgressProps

PropTypeDefaultDescription
labelstring–Give the bar a name to expose it as a `progressbar` (reading progress). Without it the bar is decorative and `aria-hidden`.

Data Attributes

State is exposed through attributes. Style it with these selectors, not with class toggles.

This component sets no state attributes.

CSS classes

ClassStylesheet
.scroll-progressscroll-progress.css
.scroll-progress-barscroll-progress.css

Customization

Style it with the kit's tokens in your own CSS, loaded after @monoline/css. Prefer the attributes above over extra classes. See Theming for every token.

app.css
.scroll-progress {
  border-color: var(--accent);
}

Accessibility

  • Decorative and aria-hidden by default.
  • With `label` it is a progressbar with aria-valuenow from 0 to 100, updated as the page scrolls.
  • No transition, so there is no motion beyond the scroll itself.