Progress Bars
UI Coding
Medium
25 min
animation
effects
timers
accessibility
Build a page with an Add button. Each click appends a new progress bar that fills from 0% to 100% over 2 seconds. Bars added later start from 0 and run alongside the ones already filling.
Requirements
- The page starts with no bars and shows a short hint ("No downloads yet").
- Each click on Add appends a bar that starts filling immediately. Several bars can fill at the same time, each on its own timeline.
- Each bar exposes its real progress to assistive tech:
role="progressbar",aria-valuenow(0–100), and a label such as "Download 1". - When a bar reaches 100% it stays full and shows "Done".
- A Clear button removes every bar.
- No leaks: removing bars or unmounting the page must cancel any running timers or animation frames.
Follow-up
- CSS transition or JavaScript animation? What does each one give you?
- What happens to your animation when the tab is in the background?
- Your bars must survive React Strict Mode's double-invoked effects. How do you know they do?
Spotted a mistake or a rights concern? Report an issue