Animated, accessible progress bar with controlled and auto modes

Create a progress/loading bar component. The component should visually indicate progress based on a percentage (0-100), support both controlled and automatic modes, and be accessible. The progress bar must be animated and show progress updates smoothly. This progress bar in React should expose the progressbar role so screen readers can announce its value.
value option (number, 0-100, default 0) to set progress percentage, and an optional auto boolean option.auto is true, the bar should automatically animate from 0% to 100% over 5 seconds, then reset.value changes, the bar should update smoothly using CSS transitions.role="progressbar", aria-valuenow, aria-valuemin, and aria-valuemax.
React: ProgressBar props
Vanilla JS: initProgressBar({ value, auto }) renders into <div id="app">, replacing what it rendered before
- value: number (between 0 and 100, default 0)
- auto?: boolean (default: false)
// Renders a horizontal progress/loading bar that visually fills up to the specified percentage.
<ProgressBar value={50} /> // or initProgressBar({ value: 50 })
// Renders a bar that is half-filled, displaying "50%" as text.
<ProgressBar auto /> // or initProgressBar({ auto: true })
// Bar animates smoothly from 0% to 100% over 5 seconds, then resets and loops.
- The progress bar must use role="progressbar". - Set aria-valuenow to the current percentage, aria-valuemin="0", and aria-valuemax="100". - The progress percentage should be visible as text for screen readers and sighted users.
- In controlled mode (value), the progress bar should respond to changes in value with a smooth width transition. - In auto mode (auto), the component manages its own state, filling from 0 to 100 over 5 seconds, then resetting. - Use CSS for the bar's appearance and transitions. - Bar must be responsive and visually clear at all percentages.
The tests render your bar with different options (React: as props; vanilla: by calling initProgressBar(options)) and read the page like a user or screen reader would. You don’t need test ids or specific class names. They only check that:
role="progressbar", aria-valuemin="0", aria-valuemax="100", and aria-valuenow set to the rounded percentage.50%. With no value it shows 0%.auto on, aria-valuenow climbs above 0 on its own within a few seconds.