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.
npm install smart-webcomponents
<script type="module" src="node_modules/smart-webcomponents/source/modules/smart.led.js"></script>
<link rel="stylesheet" type="text/css" href="node_modules/smart-webcomponents/source/styles/smart.default.css" />
div (you mount programmatically with appendTo):Semantic element (id matches the selector in Smart()):
<smart-led id="led"></smart-led>
Host container (id matches appendTo on Smart.Led):
<div id="ledContainer"></div>
div:
<script type="module">
import 'node_modules/smart-webcomponents/source/modules/smart.led.js';
const ledOptions = {};
// Option A - semantic <smart-led> with id="led"
Smart('#led', class {
get properties() {
return ledOptions;
}
});
// Option B - host div id="ledContainer"
// const ledInstance = new Smart.Led({
// ...ledOptions,
// appendTo: '#ledContainer'
// });
// Option C - constructor(selector, options), then append the returned element yourself
// const myLed = new Smart.Led('#led', ledOptions);
// document.body.appendChild(myLed);
</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.Led('#led', ledOptions) with appendChild, and document.createElement('smart-led') with .props or Object.assign (all are valid patterns; do not combine overlapping patterns for the same instance unless you intend multiple components).
Alternative creation patterns and imperative APIs. These are all valid ways to create Smart UI components: semantic markup + Smart(); new Smart.Led({ ...options, appendTo: '#...' }); new Smart.Led('#led', ledOptions) plus appendChild on the returned element; and document.createElement('smart-led') 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 myLed = new Smart.Led('#led', ledOptions)):
const ledOptions = {};
const myLed = new Smart.Led('#led', ledOptions);
document.body.appendChild(myLed);
Create with document.createElement('smart-led'), assign properties (same as any custom element), then append:
const ledOptions = {};
const led = document.createElement('smart-led');
Object.assign(led, ledOptions);
document.body.appendChild(led);
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.led.js";
document.readyState === 'complete' ? init() : window.addEventListener('load', init);
function init() {
const ledOptions = {};
const led = new Smart.Led({
...ledOptions,
appendTo: '#ledContainer'
});
}
Append to the DOM:
const container = document.getElementById('led-container');
container.appendChild(led);
Remove from the DOM:
led.remove();
Set a property:
led.disabled = true; led.theme = 'dark';
Get a property value:
const isDisabled = led.disabled; const currentTheme = led.theme;
Invoke a method:
led.refresh(); led.focus();
Add event listener:
led.addEventListener('change', (event) => {
console.log('change triggered:', event.detail.oldValue);
});
Remove event listener:
const handleLedEvent = (event) => {
console.log('change triggered:', event.detail.oldValue);
};
led.addEventListener('change', handleLedEvent);
led.removeEventListener('change', handleLedEvent);
The Led component follows WAI-ARIA best practices:
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.