Getting Started with ProgressBar Web Component
Smart UI Web Components work with current evergreen browsers and Node 18+ for local tooling; pin package versions to match your project policy.
Smart UI is distributed as the smart-webcomponents NPM package. You can also use the full download from the Download page.
Quick start
- Install the package:
npm install smart-webcomponents
- Load the ProgressBar module (ES module script):
<script type="module" src="node_modules/smart-webcomponents/source/modules/smart.progressbar.js"></script>
- Add the default stylesheet (prefer angular.json / bundler entry in app codebases; for plain HTML use a link):
<link rel="stylesheet" type="text/css" href="node_modules/smart-webcomponents/source/styles/smart.default.css" />
- Add markup in one of two ways - semantic custom element (the component tag is in your HTML) or a host
div(you mount programmatically with appendTo):
Semantic element (id matches the selector in Smart()):
<smart-progress-bar id="progressbar"></smart-progress-bar>
Host container (id matches appendTo on Smart.ProgressBar):
<div id="progressbarContainer"></div>
- Initialize after the module loads: define a const progressbarOptions object, then either bind with Smart('#progressbar', ...) on the semantic tag or use new Smart.ProgressBar({ ...progressbarOptions, appendTo: '#progressbarContainer' }) on the host
div:
<script type="module"> import 'node_modules/smart-webcomponents/source/modules/smart.progressbar.js'; const progressbarOptions = { value: 50 }; // Option A - semantic <smart-progress-bar> with id="progressbar" Smart('#progressbar', class { get properties() { return progressbarOptions; } }); // Option B - host div id="progressbarContainer" // const progressbarInstance = new Smart.ProgressBar({ // ...progressbarOptions, // appendTo: '#progressbarContainer' // }); // Option C - constructor(selector, options), then append the returned element yourself // const myProgressBar = new Smart.ProgressBar('#progressbar', progressbarOptions); // document.body.appendChild(myProgressBar); </script>
Uncomment Option B when you use the host
div; use Option A when you use the semantic element. The Runtime cookbook also documents new Smart.ProgressBar('#progressbar', progressbarOptions) with appendChild, and document.createElement('smart-progress-bar') with .props or Object.assign (all are valid patterns; do not combine overlapping patterns for the same instance unless you intend multiple components). - Serve the folder over HTTP (or use your bundler dev server) and open the page.
Runtime cookbook
Alternative creation patterns and imperative APIs. These are all valid ways to create Smart UI components: semantic markup + Smart(); new Smart.ProgressBar({ ...options, appendTo: '#...' }); new Smart.ProgressBar('#progressbar', progressbarOptions) plus appendChild on the returned element; and document.createElement('smart-progress-bar') then assigning options via .props or Object.assign on the element.
Constructor with a selector string and options, then append the returned element (for example const myProgressBar = new Smart.ProgressBar('#progressbar', progressbarOptions)):
const progressbarOptions = { value: 50 };
const myProgressBar = new Smart.ProgressBar('#progressbar', progressbarOptions);
document.body.appendChild(myProgressBar);
Create with document.createElement('smart-progress-bar'), assign properties (same as any custom element), then append:
const progressbarOptions = { value: 50 };
const progressbar = document.createElement('smart-progress-bar');
Object.assign(progressbar, progressbarOptions);
document.body.appendChild(progressbar);
Host on a div with appendTo (import the module, then instantiate when the document is ready; the container id must match appendTo):
import "../../source/modules/smart.progressbar.js";
document.readyState === 'complete' ? init() : window.addEventListener('load', init);
function init() {
const progressbarOptions = { value: 50 };
const progressbar = new Smart.ProgressBar({
...progressbarOptions,
appendTo: '#progressbarContainer'
});
}
Demo
Appearance
To set the value of the progress bar the user has to apply a value to the value property as an HTML attribute:
<smart-progress-bar value="50"></smart-progress-bar> <smart-circular-progress-bar value="50"></smart-circular-progress-bar>
Demo
or using javascript:
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="../../source/styles/smart.default.css" type="text/css" />
<script type="text/javascript" src="../../source/modules/smart.progressbar.js"></script>
<script>
window.onload = function () {
document.querySelector('smart-progress-bar').value = 25;
document.querySelector('smart-circular-progress-bar').value = 25;
}
</script>
</head>
<body>
<smart-progress-bar></smart-progress-bar>
<smart-circular-progress-bar></smart-circular-progress-bar>
</body>
</html>
Demo
The direction of the progress can be inverted by applying the inverted property:
<smart-progress-bar value="25" inverted></smart-progress-bar> <smart-circular-progress-bar value="25" inverted></smart-circular-progress-bar>
Demo
The linear progress bar has two orientation types:
- Horizontal - the fill increases from left to right.
- Vertical - the fill increases from top to bottom.
The orientation property is responsible for the orientation of the element:
<smart-progress-bar value="25" orientation="vertical"></smart-progress-bar>
Demo
Behavior
By default the progress bar is used to visually display the progress of a process using it's fill. However the element allows numeric indication of the progress as well. This can be enabled by setting the showProgressValue property:
<smart-progress-bar show-progress-value value="54"></smart-progress-bar>
Demo
The progress indicator is placed in the middle of the progress bar and can be customized. The formatFunction property allows the user to control what text is displayed. Here's how to apply a custom formatting function:
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="../../source/styles/smart.default.css" type="text/css" />
<script type="text/javascript" src="../../source/modules/smart.progressbar.js"></script>
<script>
window.onload = function () {
var progressBar = document.querySelector('smart-progress-bar');
progressBar.formatFunction = function (value) {
return value + ' ' + 'oz';
}
}
</script>
</head>
<body>
<smart-progress-bar show-progress-value value="54"></smart-progress-bar>
</body>
</html>
Demo
The start and end value of the element can be reconfigured using the min and max property:
<smart-progress-bar value="54" min="20" max="70"></smart-progress-bar> <smart-circular-progress-bar value="54" min="20" max="70"></smart-circular-progress-bar>
Demo
Progress bars are often used as loading indicators. For this purpose the user can set the indeterminate property and the progress bar will start an indeterminate animation which can be stopped any time by removing the attribute:
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="../../source/styles/smart.default.css" type="text/css" />
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/0.7.22/webcomponents-lite.min.js"></script>
<script type="text/javascript" src="../../source/Smart.element.js"></script>
<script type="text/javascript" src="../../source/Smart.progressbar.js"></script>
<script>
window.onload = function () {
var progressBar = document.querySelector('smart-progress-bar');
progressBar.indeterminate = false;
}
</script>
</head>
<body>
<smart-progress-bar indeterminate></smart-progress-bar>
</body>
</html>
Demo
The user can also set the progress bar to indeterminate state by setting the value property to null.
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="../../source/styles/smart.default.css" type="text/css" />
<script type="text/javascript" src="../../source/modules/smart.progressbar.js"></script>
<script>
window.onload = function () {
var progressBar = document.querySelector('smart-circular-progress-bar');
progressBar.value = null;
}
</script>
</head>
<body>
<smart-circular-progress-bar></smart-circular-progress-bar>
</body>
</html>
Demo
Append to the DOM:
const container = document.getElementById('progressbar-container');
container.appendChild(progressbar);
Remove from the DOM:
progressbar.remove();
Set a property:
progressbar.disabled = true; progressbar.theme = 'dark';
Get a property value:
const isDisabled = progressbar.disabled; const currentTheme = progressbar.theme;
Invoke a method:
progressbar.refresh(); progressbar.focus();
Add event listener:
progressbar.addEventListener('change', (event) => {
console.log('change triggered:', event.detail);
});
Remove event listener:
const handleProgressBarEvent = (event) => {
console.log('change triggered:', event.detail);
};
progressbar.addEventListener('change', handleProgressBarEvent);
progressbar.removeEventListener('change', handleProgressBarEvent);
Accessibility
The ProgressBar component follows WAI-ARIA best practices:
- Keyboard navigation - Tab, Arrow keys, Enter, and Escape are supported
- ARIA roles - Appropriate roles and labels are applied automatically
- Focus management - Visible focus indicators for keyboard users
- Screen readers - State changes are announced to assistive technology
- High contrast - Supports Windows High Contrast Mode and forced colors
For custom labeling, set aria-label or aria-labelledby attributes on the component.
Supported stacks: Smart UI targets Angular 17+, React 18+, Vue 3+, Node 18 LTS, and evergreen browsers; pin exact package versions to your org policy.