Led — Smart UI JavaScript API
On this page + Quick start
Quick start · JavaScript
Complete starter source per framework. Run the scaffold/install command first, then replace the listed files with the full code below.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Led - JavaScript Quick Start</title>
<link rel="stylesheet" href="./node_modules/smart-webcomponents/source/styles/smart.default.css" />
</head>
<body>
<smart-led id="demo-led"></smart-led>
<script type="module">
import './node_modules/smart-webcomponents/source/modules/smart.led.js';
const el = document.getElementById('demo-led');
if (el) {
el.value = true;
el.addEventListener('change', (event) => console.log('change:', event.detail || event));
}
</script>
</body>
</html>
For AI tooling
Developer Quick Reference
Component: Led Framework: JavaScript Selector: smart-led
API counts: 22 properties, 0 methods, 1 events
Common properties: 0, 1, 2, 3, 4, 5
Common methods: n/a
Common events: change
Module hint: smart-webcomponents/source/modules/smart.led.js
LET Toggle button with Checked boolean value.
Class
Led
LET Toggle button with Checked boolean value.
Selector
smart-led
Properties
Events
Properties
animationSets or retrieves the current animation mode. When this property is set to 'none', all animations are disabled, and elements will display or update instantly without any transition effects. For other values, the specified animation mode will determine how visual changes are animated."none" | "simple" | "advanced"
Sets or retrieves the current animation mode. When this property is set to 'none', all animations are disabled, and elements will display or update instantly without any transition effects. For other values, the specified animation mode will determine how visual changes are animated.
Allowed Values
- "none" - animation is disabled
- "simple" - ripple animation is disabled
- "advanced" - all animations are enabled
Default value
"advanced"Examples
Markup and runtime examples for animation:
HTML:
<smart-led animation="none"></smart-led>
Vanilla JS — prefer #id if multiple widgets exist on the page:
const el = document.querySelector('smart-led');
el.animation = "simple";Read the current value:
const el = document.querySelector('smart-led');
const animation = el.animation;
checkedGets the current check state or sets it to a specified value, typically used for checkbox, radio button, or similar UI elements. The check state indicates whether the element is checked, unchecked, or (if supported) in an indeterminate state.boolean
Gets the current check state or sets it to a specified value, typically used for checkbox, radio button, or similar UI elements. The check state indicates whether the element is checked, unchecked, or (if supported) in an indeterminate state.
Default value
falseExamples
Markup and runtime examples for checked:
HTML attribute:
<smart-led checked></smart-led>
Vanilla JS — prefer #id if multiple widgets exist on the page:
const el = document.querySelector('smart-led');
el.checked = false;Read the current value:
const el = document.querySelector('smart-led');
const checked = el.checked;
clickModeSpecifies the conditions under which the element will trigger a click event, allowing you to control when and how user interactions or programmatic actions cause the click event to be fired."hover" | "press" | "release" | "pressAndRelease"
Specifies the conditions under which the element will trigger a click event, allowing you to control when and how user interactions or programmatic actions cause the click event to be fired.
Allowed Values
- "hover" - Fires a click event on hover and sets the element to clicked state.
- "press" - Fires a click event on press and sets the element to clicked state.
- "release" - Fires a click event on release and sets the element to clicked state.
- "pressAndRelease" - Fires a click event on press and a second click event on release and then sets the element to clicked state.
Default value
"release"Examples
Markup and runtime examples for clickMode:
HTML:
<smart-led click-mode="press"></smart-led>
Vanilla JS — prefer #id if multiple widgets exist on the page:
const el = document.querySelector('smart-led');
el.clickMode = "pressAndRelease";Read the current value:
const el = document.querySelector('smart-led');
const clickMode = el.clickMode;
disabledControls the LED's power state by enabling (turning on) or disabling (turning off) the LED.boolean
Controls the LED's power state by enabling (turning on) or disabling (turning off) the LED.
Default value
falseExamples
Markup and runtime examples for disabled:
HTML attribute:
<smart-led disabled></smart-led>
Vanilla JS — prefer #id if multiple widgets exist on the page:
const el = document.querySelector('smart-led');
el.disabled = false;Read the current value:
const el = document.querySelector('smart-led');
const disabled = el.disabled;
falseContentSpecifies the content to be displayed when the state is set to 'false'.string
Specifies the content to be displayed when the state is set to 'false'.
Default value
""""Examples
Markup and runtime examples for falseContent:
HTML:
<smart-led false-content="OFF"></smart-led>
Vanilla JS — prefer #id if multiple widgets exist on the page:
const el = document.querySelector('smart-led');
el.falseContent = "False";Read the current value:
const el = document.querySelector('smart-led');
const falseContent = el.falseContent;
falseTemplateDefines a custom template that determines the LED's appearance or behavior when it is in the "off" or false state.any
Defines a custom template that determines the LED's appearance or behavior when it is in the "off" or false state.
Examples
Markup and runtime examples for falseTemplate:
HTML:
<smart-led false-template="templateId1"></smart-led>
Vanilla JS — prefer #id if multiple widgets exist on the page:
const el = document.querySelector('smart-led');
el.falseTemplate = "templateId2";Read the current value:
const el = document.querySelector('smart-led');
const falseTemplate = el.falseTemplate;
indeterminateConfigures the LED to display an indeterminate state, typically represented by a blinking or animated pattern to indicate ongoing activity or a process with an unknown completion time. This is useful for scenarios where the system cannot determine or communicate a specific status or progress value.boolean
Configures the LED to display an indeterminate state, typically represented by a blinking or animated pattern to indicate ongoing activity or a process with an unknown completion time. This is useful for scenarios where the system cannot determine or communicate a specific status or progress value.
Default value
falseExamples
Markup and runtime examples for indeterminate:
HTML attribute:
<smart-led indeterminate></smart-led>
Vanilla JS — prefer #id if multiple widgets exist on the page:
const el = document.querySelector('smart-led');
el.indeterminate = false;Read the current value:
const el = document.querySelector('smart-led');
const indeterminate = el.indeterminate;
indeterminateContentDefines the content to be displayed when the component is in a 'null' or empty state, such as when no data is available or the value is undefined.string
Defines the content to be displayed when the component is in a 'null' or empty state, such as when no data is available or the value is undefined.
Default value
""""Examples
Markup and runtime examples for indeterminateContent:
HTML:
<smart-led indeterminate-content=""></smart-led>
Vanilla JS — prefer #id if multiple widgets exist on the page:
const el = document.querySelector('smart-led');
el.indeterminateContent = "Indeterminate";Read the current value:
const el = document.querySelector('smart-led');
const indeterminateContent = el.indeterminateContent;
indeterminateTemplateDefines a custom template to visually represent the LED component when it is in an indeterminate state, allowing you to specify the appearance or behavior of the LED during this undefined or transitional state.any
Defines a custom template to visually represent the LED component when it is in an indeterminate state, allowing you to specify the appearance or behavior of the LED during this undefined or transitional state.
Examples
Markup and runtime examples for indeterminateTemplate:
HTML:
<smart-led indeterminate-template="templateId1"></smart-led>
Vanilla JS — prefer #id if multiple widgets exist on the page:
const el = document.querySelector('smart-led');
el.indeterminateTemplate = "templateId2";Read the current value:
const el = document.querySelector('smart-led');
const indeterminateTemplate = el.indeterminateTemplate;
localeSpecifies or retrieves the current language setting for localization purposes. This property works together with the messages property to display interface text and messages in the selected language. When you set this property, the corresponding localized messages from messages are used throughout the application.string
Specifies or retrieves the current language setting for localization purposes. This property works together with the messages property to display interface text and messages in the selected language. When you set this property, the corresponding localized messages from messages are used throughout the application.
Default value
"en"Examples
Markup and runtime examples for locale:
HTML:
<smart-led locale="de"></smart-led>
Vanilla JS — prefer #id if multiple widgets exist on the page:
const el = document.querySelector('smart-led');
el.locale = "fr";Read the current value:
const el = document.querySelector('smart-led');
const locale = el.locale;
localizeFormatFunctionA callback function that allows you to customize the formatting of messages returned by the Localization Module. Use this to modify or enhance localized messages—such as applying custom templates, injecting dynamic content, or adjusting formatting—before they are delivered to the user interface.function | null
A callback function that allows you to customize the formatting of messages returned by the Localization Module. Use this to modify or enhance localized messages—such as applying custom templates, injecting dynamic content, or adjusting formatting—before they are delivered to the user interface.
Examples
Markup and runtime examples for localizeFormatFunction:
HTML:
<smart-led localize-format-function="function(defaultMessage, message, messageArguments){return '...'}"></smart-led>Vanilla JS — prefer #id if multiple widgets exist on the page:
const el = document.querySelector('smart-led');
el.localizeFormatFunction = "function(defaultMessage, message, messageArguments){return '...'}";Read the current value:
const el = document.querySelector('smart-led');
const localizeFormatFunction = el.localizeFormatFunction;
messagesDefines or retrieves an object containing localized strings used by the widget's user interface, such as labels, messages, and tooltips. This property works in tandem with the locale property to enable support for multiple languages, allowing developers to customize text displayed to users based on their selected language or region.object
Defines or retrieves an object containing localized strings used by the widget's user interface, such as labels, messages, and tooltips. This property works in tandem with the locale property to enable support for multiple languages, allowing developers to customize text displayed to users based on their selected language or region.
Default value
"en": {
"propertyUnknownType": "'{{name}}' property is with undefined 'type' member!",
"propertyInvalidValue": "Invalid '{{name}}' property value! Actual value: {{actualValue}}, Expected value: {{value}}!",
"propertyInvalidValueType": "Invalid '{{name}}' property value type! Actual type: {{actualType}}, Expected type: {{type}}!",
"elementNotInDOM": "Element does not exist in DOM! Please, add the element to the DOM, before invoking a method.",
"moduleUndefined": "Module is undefined.",
"missingReference": "{{elementType}}: Missing reference to {{files}}.",
"htmlTemplateNotSuported": "{{elementType}}: Browser doesn't support HTMLTemplate elements.",
"invalidTemplate": "{{elementType}}: '{{property}}' property accepts a string that must match the id of an HTMLTemplate element from the DOM."
}
Examples
Markup and runtime examples for messages:
HTML:
<smart-led messages="{"de":{"propertyUnknownType":"Die Eigenschaft '{{name}}' hat ein nicht definiertes 'type'-Member!","propertyInvalidValue":"Ungultiger Eigenschaftswert '{{name}}'! Aktueller Wert: {{actualValue}}, Erwarteter Wert: {{value}}!","propertyInvalidValueType":"Ungultiger Eigenschaftswert '{{name}}'! Aktueller Wert: {{actualType}}, Erwarteter Wert: {{type}}!","elementNotInDOM":"Element existiert nicht in DOM! Bitte fugen Sie das Element zum DOM hinzu, bevor Sie eine Methode aufrufen.","moduleUndefined":"Modul ist nicht definiert.","missingReference":"{{elementType}}: Fehlender Verweis auf {{files}}.","htmlTemplateNotSuported":"{{elementType}}: Browser unterstutzt keine HTMLTemplate-Elemente.","invalidTemplate":"{{elementType}}: '{{property}}' Die Eigenschaft akzeptiert eine Zeichenfolge, die mit der ID eines HTMLTemplate-Elements aus dem DOM ubereinstimmen muss."}}"></smart-led>Vanilla JS — prefer #id if multiple widgets exist on the page:
const el = document.querySelector('smart-led');
el.messages = {"en":{"propertyUnknownType":"'{{name}}' property is with undefined 'type' member!","propertyInvalidValue":"Invalid '{{name}}' property value! Actual value: {{actualValue}}, Expected value: {{value}}!","propertyInvalidValueType":"Invalid '{{name}}' property value type! Actual type: {{actualType}}, Expected type: {{type}}!","elementNotInDOM":"Element does not exist in DOM! Please, add the element to the DOM, before invoking a method.","moduleUndefined":"Module is undefined.","missingReference":"{{elementType}}: Missing reference to {{files}}.","htmlTemplateNotSuported":"{{elementType}}: Browser doesn't support HTMLTemplate elements.","invalidTemplate":"{{elementType}}: '{{property}}' property accepts a string that must match the id of an HTMLTemplate element from the DOM."}};Read the current value:
const el = document.querySelector('smart-led');
const messages = el.messages;
nameSets or retrieves the value of the element's name attribute. The name attribute is used to identify form elements when submitting HTML forms, allowing their values to be sent to the server as key-value pairs. This attribute is essential for collecting user input in form processing.string
Sets or retrieves the value of the element's name attribute. The name attribute is used to identify form elements when submitting HTML forms, allowing their values to be sent to the server as key-value pairs. This attribute is essential for collecting user input in form processing.
Default value
""""Examples
Markup and runtime examples for name:
HTML:
<smart-led name="Name"></smart-led>
Vanilla JS — prefer #id if multiple widgets exist on the page:
const el = document.querySelector('smart-led');
el.name = "New Name";Read the current value:
const el = document.querySelector('smart-led');
const name = el.name;
readonlyIf the widget is set to read-only, users will be unable to interact with the element or modify its contents. All input and editing functionalities will be disabled, ensuring that the information displayed remains unchanged by the user.boolean
If the widget is set to read-only, users will be unable to interact with the element or modify its contents. All input and editing functionalities will be disabled, ensuring that the information displayed remains unchanged by the user.
Default value
falseExamples
Markup and runtime examples for readonly:
HTML attribute:
<smart-led readonly></smart-led>
Vanilla JS — prefer #id if multiple widgets exist on the page:
const el = document.querySelector('smart-led');
el.readonly = true;Read the current value:
const el = document.querySelector('smart-led');
const readonly = el.readonly;
rightToLeftSets or retrieves the value that determines whether the element’s content is aligned to support languages that use right-to-left (RTL) scripts, such as Arabic or Hebrew. This property ensures proper text direction and alignment for locales requiring RTL formatting.boolean
Sets or retrieves the value that determines whether the element’s content is aligned to support languages that use right-to-left (RTL) scripts, such as Arabic or Hebrew. This property ensures proper text direction and alignment for locales requiring RTL formatting.
Default value
falseExamples
Markup and runtime examples for rightToLeft:
HTML attribute:
<smart-led right-to-left></smart-led>
Vanilla JS — prefer #id if multiple widgets exist on the page:
const el = document.querySelector('smart-led');
el.rightToLeft = false;Read the current value:
const el = document.querySelector('smart-led');
const rightToLeft = el.rightToLeft;
shapeSpecifies the geometric shape or appearance of the LED component, such as circle, square, rectangle, or custom shapes. This setting determines how the LED will be visually rendered in the user interface."round" | "square"
Specifies the geometric shape or appearance of the LED component, such as circle, square, rectangle, or custom shapes. This setting determines how the LED will be visually rendered in the user interface.
Allowed Values
- "round" - The LED represents a circle.
- "square" - The LED representsa a square.
Default value
"round"Examples
Markup and runtime examples for shape:
HTML:
<smart-led shape="square"></smart-led>
Vanilla JS — prefer #id if multiple widgets exist on the page:
const el = document.querySelector('smart-led');
el.shape = "round";Read the current value:
const el = document.querySelector('smart-led');
const shape = el.shape;
themeSpecifies the theme to be applied, which controls the visual appearance—such as colors, fonts, and styles—of the element. The selected theme ensures a consistent and cohesive look and feel across the user interface.string
Specifies the theme to be applied, which controls the visual appearance—such as colors, fonts, and styles—of the element. The selected theme ensures a consistent and cohesive look and feel across the user interface.
Default value
""Examples
Markup and runtime examples for theme:
HTML:
<smart-led theme="blue"></smart-led>
Vanilla JS — prefer #id if multiple widgets exist on the page:
const el = document.querySelector('smart-led');
el.theme = "red";Read the current value:
const el = document.querySelector('smart-led');
const theme = el.theme;
trueContentSpecifies the content that will be displayed or rendered when the associated state is evaluated as 'true'.string
Specifies the content that will be displayed or rendered when the associated state is evaluated as 'true'.
Default value
""""Examples
Markup and runtime examples for trueContent:
HTML:
<smart-led true-content="ON"></smart-led>
Vanilla JS — prefer #id if multiple widgets exist on the page:
const el = document.querySelector('smart-led');
el.trueContent = "True";Read the current value:
const el = document.querySelector('smart-led');
const trueContent = el.trueContent;
trueTemplateSpecifies a custom template that defines the behavior or appearance of the LED when its state is set to "true" (on). Use this template to customize how the LED should be displayed or controlled when activated.any
Specifies a custom template that defines the behavior or appearance of the LED when its state is set to "true" (on). Use this template to customize how the LED should be displayed or controlled when activated.
Examples
Markup and runtime examples for trueTemplate:
HTML:
<smart-led true-template="templateId1"></smart-led>
Vanilla JS — prefer #id if multiple widgets exist on the page:
const el = document.querySelector('smart-led');
el.trueTemplate = "templateId2";Read the current value:
const el = document.querySelector('smart-led');
const trueTemplate = el.trueTemplate;
unfocusableWhen set to true, this property prevents the element from receiving keyboard focus, making it inaccessible via tab navigation or scripting methods such as element.focus().boolean
When set to true, this property prevents the element from receiving keyboard focus, making it inaccessible via tab navigation or scripting methods such as element.focus().
Default value
falseExamples
Markup and runtime examples for unfocusable:
HTML attribute:
<smart-led unfocusable></smart-led>
Vanilla JS — prefer #id if multiple widgets exist on the page:
const el = document.querySelector('smart-led');
el.unfocusable = false;Read the current value:
const el = document.querySelector('smart-led');
const unfocusable = el.unfocusable;
unlockKeySets or retrieves the unlockKey, a unique identifier or code required to unlock access to the product. This property allows you to manage product access by specifying or obtaining the key needed for unlocking restricted features or content.string
Sets or retrieves the unlockKey, a unique identifier or code required to unlock access to the product. This property allows you to manage product access by specifying or obtaining the key needed for unlocking restricted features or content.
Default value
""Examples
Markup and runtime examples for unlockKey:
HTML:
<smart-led unlock-key=""></smart-led>
Vanilla JS — prefer #id if multiple widgets exist on the page:
const el = document.querySelector('smart-led');
el.unlockKey = "1111-2222-3333-4444-5555";Read the current value:
const el = document.querySelector('smart-led');
const unlockKey = el.unlockKey;
valueSets a new value for the element or retrieves its current value, depending on whether an argument is provided. This is commonly used for form elements such as input, select, or textarea to programmatically update or access their contents.string
Sets a new value for the element or retrieves its current value, depending on whether an argument is provided. This is commonly used for form elements such as input, select, or textarea to programmatically update or access their contents.
Default value
""""Examples
Markup and runtime examples for value:
HTML:
<smart-led value="Value"></smart-led>
Vanilla JS — prefer #id if multiple widgets exist on the page:
const el = document.querySelector('smart-led');
el.value = "New Value";Read the current value:
const el = document.querySelector('smart-led');
const value = el.value;
Events
changeThis event is triggered whenever the widget’s checked state changes, that is, when the user selects (checks) or deselects (unchecks) the widget. It allows you to execute custom logic in response to the widget being either checked or unchecked.CustomEvent
This event is triggered whenever the widget’s checked state changes, that is, when the user selects (checks) or deselects (unchecks) the widget. It allows you to execute custom logic in response to the widget being either checked or unchecked.
- Bubbles Yes
- Cancelable No
- Interface CustomEvent
- Event handler property onChange
Arguments
evCustomEvent
ev.detailObject
ev.detail.oldValue - The previous value of the element before it was changed.
ev.detail.value - The new value of the element.
Methods
isDefaultPrevented
Returns true if the event was prevented by any of its subscribers.
Returns
boolean true if the default action was prevented. Otherwise, returns false.
preventDefault
The preventDefault() method prevents the default action for a specified event. In this way, the source component suppresses the built-in behavior that follows the event.
stopPropagation
The stopPropagation() method of the Event interface prevents further propagation of the current event in the capturing and bubbling phases.
Examples
Listen for change using the pattern that matches your stack.
DOM — listen on the custom element (use a specific selector if the page has more than one):
document.querySelector('smart-led')?.addEventListener('change', (event) => {
const detail = event.detail,
oldValue = detail.oldValue,
value = detail.value;
// event handling code goes here.
})
CSS Variables
--smart-led-default-widthvar()
Default value
"var(--smart-editor-height)"smartLed default width
--smart-led-default-heightvar()
Default value
"var(--smart-editor-height)"smartLed default height