Skip to main content
Frontend tutorial

8.3. Progress and capacity

The shipment fits ten pallets, but the counter happily goes on to eleven. Let's show how full it is and stop at ten.

ProgressIndicator draws the bar. Its value is a percentage from 0 to 100, so turn the count into one. Give the ten a name, capacity, and use it everywhere. When loaded reaches it, disabled switches Load pallet off.

import { Button } from '@ui5/webcomponents-react/Button';
import { ProgressIndicator } from '@ui5/webcomponents-react/ProgressIndicator';
import '@ui5/webcomponents-icons/dist/add.js';
import '@ui5/webcomponents-icons/dist/refresh.js';
import './styles.css';

const capacity = 10;
<p>{loaded} / {capacity} pallets loaded</p>
<ProgressIndicator
value={(loaded / capacity) * 100}
accessibleName="Shipment loading"
/>
<Button
icon="add"
design="Emphasized"
disabled={loaded >= capacity}
onClick={() => setLoaded(loaded + 1)}
>
Load pallet
</Button>
Need a hint?
  • value is a percentage from 0 to 100, not a pallet count.
  • disabled={loaded >= capacity} turns the button off; Reset turns it back on.

Load until the bar is full. At ten the button stops, and Reset starts a new shipment.

Work locally

You need Node.js 24, pnpm and Git (how to set them up). Clone this step’s starting code:

git clone --depth 1 \
--branch lesson-08-03-progress-and-capacity-start-v6 \
https://github.com/adam-zielonka/frontend-tutorial.git \
08-03-progress-and-capacity
cd 08-03-progress-and-capacity
pnpm install --frozen-lockfile
pnpm dev

To keep your own commits: git switch -c my-work.

Browse the source on GitHub (opens in a new tab)

Bring your browser edits

Choose Download my files in the ⋯ menu. It saves the lesson’s files as JSON. Stop the local server with Ctrl+C, copy the download into the project folder and run:

node import-draft.mjs ./08-03-progress-and-capacity-my-files.json
pnpm dev

The import replaces the project’s exercise files, so commit or back up local edits first.

Loading this step’s code…
Starting the live preview…