ViewProgress
Scrubs a --ui-view-progress number from 0 to 1 on its own root for scroll-linked styles without JavaScript.
- Frameworks
- Astro · React · Elements · Dioxus
- Registry
lumen add ViewProgress- Interaction
- Native markup
See it and copy it
Framework example
Choose Astro, React, Elements, or Dioxus to compare native usage against the shared visual output. Each example assumes the framework-level setup is already complete.
An arc that settles as you scroll
The top corners of this sheet flatten while it moves through the viewport. Without scroll-driven animations, or with reduced motion, it shows the finished flat state.
View ViewProgress code
Framework usage
Switch targets to compare the adapter code. This live preview runs the Astro example. Before copying an example, complete the matching framework setup; React, Elements, and Dioxus use their own behavior APIs.Width controls resize the preview container. Resize your browser to test viewport breakpoints.---
import { Separator, Typography, ViewProgress } from '@santi020k/lumen-astro'
---
<ViewProgress
style="padding: 1.5rem; background: hsl(var(--surface-muted)); border-start-start-radius: calc((1 - var(--ui-view-progress)) * 4rem); border-start-end-radius: calc((1 - var(--ui-view-progress)) * 4rem);"
>
<Typography>
<p><strong>An arc that settles as you scroll</strong></p>
<p>The top corners of this sheet flatten while it moves through the viewport. Without scroll-driven animations, or with reduced motion, it shows the finished flat state.</p>
</Typography>
<Separator style="--ui-view-progress: inherit; inline-size: calc(var(--ui-view-progress) * 100%); margin-block-start: 1rem;" />
</ViewProgress>import type { CSSProperties } from 'react'
import { Separator, Typography, ViewProgress } from '@santi020k/lumen-react'
const exampleStyle0: CSSProperties & Record<`--${string}`, string | number> = { "padding": "1.5rem", "background": "hsl(var(--surface-muted))", "borderStartStartRadius": "calc((1 - var(--ui-view-progress)) * 4rem)", "borderStartEndRadius": "calc((1 - var(--ui-view-progress)) * 4rem)" }
const exampleStyle1: CSSProperties & Record<`--${string}`, string | number> = { "--ui-view-progress": "inherit", "inlineSize": "calc(var(--ui-view-progress) * 100%)", "marginBlockStart": "1rem" }
export const Example = () => (
<>
<ViewProgress
style={exampleStyle0}
>
<Typography>
<p><strong>An arc that settles as you scroll</strong></p>
<p>The top corners of this sheet flatten while it moves through the viewport. Without scroll-driven animations, or with reduced motion, it shows the finished flat state.</p>
</Typography>
<Separator style={exampleStyle1} />
</ViewProgress>
</>
)<script type="module">
import { defineLumenElements } from '@santi020k/lumen-elements/define'
defineLumenElements()
</script>
<lumen-view-progress
style="padding: 1.5rem; background: hsl(var(--surface-muted)); border-start-start-radius: calc((1 - var(--ui-view-progress)) * 4rem); border-start-end-radius: calc((1 - var(--ui-view-progress)) * 4rem);">
<lumen-typography>
<p><strong>An arc that settles as you scroll</strong></p>
<p>The top corners of this sheet flatten while it moves through the viewport. Without scroll-driven animations, or with reduced motion, it shows the finished flat state.</p>
</lumen-typography>
<lumen-separator style="--ui-view-progress: inherit; inline-size: calc(var(--ui-view-progress) * 100%); margin-block-start: 1rem;"></lumen-separator>
</lumen-view-progress>use dioxus::prelude::*;
use lumen_dioxus::prelude::*;
#[component]
fn Example() -> Element {
rsx! {
ViewProgress { range: ViewProgressRange::Entry,
div { class: "ui-card", "Progress follows the scroll position." }
}
}
}Framework differences
Choose your target
Add this component
Choose the package for your runtime. All adapters share the Lumen stylesheet. Use the matching registry command when you want a local wrapper for that framework.
pnpm add @santi020k/lumen-astrolumen add ViewProgresspnpm add @santi020k/lumen-reactlumen add ViewProgress --target reactpnpm add @santi020k/lumen-elementslumen add ViewProgress --target elementsAPI reference
Lumen-specific props and runtime attributes for the Astro primitive. Use the framework differences above and the copyable examples for React composition and Elements attributes; the public adapter types define their supported contracts.
| Attribute | Values | Default | Description |
|---|---|---|---|
| as | "div" | "section" | "article" | "div" | Sets the semantic root. The React root is a div and the Elements root is the element itself. |
| range | "cover" | "contain" | "entry" | "exit" | "cover" | Selects the part of the root's pass through the viewport that maps to 0–1. Unknown values use cover. Adds the matching .ui-view-progress--{range} class. |
| CSS variables | --ui-view-progress: registered <number>, 0–1, not inherited | 1 | Runs from 0 to 1 on the root itself while it crosses the viewport, with no JavaScript. Style the root through class with calc(), for example calc((1 - var(--ui-view-progress)) * 4rem). Because it is not inherited, only the root restyles; a descendant opts in with --ui-view-progress: inherit. |
| static state / reduced motion | system preference or data-ui-motion="reduce" | 1 | Rests at 1 where scroll-driven animations are unsupported and under reduced motion. Design the 1 state as the intended static appearance and keep text readable at every value. |
| CSS hooks | .ui-view-progress / .ui-view-progress--cover | --contain | --entry | --exit | - | Class hooks on the root. Target the root through your own class rather than these hooks when styling a scrubbed frame. |
| class, className | string | "" | Merges custom classes with the generated ui-* root classes. |
| ...native attributes | HTML attributes | - | Forwards standard attributes to the root element unless the component consumes them. |
Customize ViewProgress
Start with semantic theme tokens and a class on the public component. Keep its accessible name, focus treatment, and interaction state intact.
.product-view-progress {
--surface: 0 0% 100%;
--ink: 220 20% 15%;
--line: 220 15% 82%;
}Apply product-view-progress through Astro's class, React's className, or the custom element's class. Verify foreground and background contrast in both schemes.
Documented styling parts: view-progress view-progress--cover view-progress--contain view-progress--entry view-progress--exit
| Hook | Values | Default | Contract |
|---|---|---|---|
| CSS variables | --ui-view-progress: registered <number>, 0–1, not inherited | 1 | Runs from 0 to 1 on the root itself while it crosses the viewport, with no JavaScript. Style the root through class with calc(), for example calc((1 - var(--ui-view-progress)) * 4rem). Because it is not inherited, only the root restyles; a descendant opts in with --ui-view-progress: inherit. |
| CSS hooks | .ui-view-progress / .ui-view-progress--cover | --contain | --entry | --exit | - | Class hooks on the root. Target the root through your own class rather than these hooks when styling a scrubbed frame. |
| class, className | string | "" | Merges custom classes with the generated ui-* root classes. |
Use the documented hooks above and adapter types when targeting component states. Theme guide · Accessibility verification scope