Scroll progress
A thin bar fixed to the top of the window that fills as the page scrolls.
SourceStyles source@monoline/react 0.5.0Markdown for AI toolsstable
- 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
Props
ScrollProgressProps
| Prop | Type | Default | Description |
|---|---|---|---|
label | string | – | 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
| Class | Stylesheet |
|---|---|
.scroll-progress | scroll-progress.css |
.scroll-progress-bar | scroll-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.