Button
Buttons allow users to take actions, and make choices, with a single tap. Buttons communicate actions that users can take.
Selector
smart-button
Properties
Events
Properties
animation"none" | "simple" | "advanced"
Specifies the animation mode for the element. When set to 'none', all animations are disabled. Use this property to enable, disable, or customize the animation behavior as needed. You can get the current animation mode or assign a new value to control how animations are applied.
Allowed Values
- "none" - animation is disabled
- "simple" - ripple animation is disabled
- "advanced" - all animations are enabled
Default value
"advanced"Example
Set the animation property.
<smart-button animation='none'></smart-button>
Set the animation property by using the HTML Element's instance.
const button = document.querySelector('smart-button');
button.animation = 'simple';
Get the animation property.
const button = document.querySelector('smart-button');
let animation = button.animation;
clickMode"hover" | "press" | "release" | "pressAndRelease"
Specifies how the element responds to user click interactions, such as triggering specific actions, toggling states, or initiating custom event handling based on the selected mode.
Allowed Values
- "hover" - The element fires a click event when hovered.
- "press" - The element fires a click event when pressed.
- "release" - The element fires a click event when released.
- "pressAndRelease" - The element fires a click event when pressed and again when released.
Default value
"release"Example
Set the clickMode property.
<smart-button click-mode='hover'></smart-button>
Set the clickMode property by using the HTML Element's instance.
const button = document.querySelector('smart-button');
button.clickMode = 'release';
Get the clickMode property.
const button = document.querySelector('smart-button');
let clickMode = button.clickMode;
contentany
Specifies the inner content of the element, such as text, HTML, or child elements, determining what is displayed inside the element on the web page.
Default value
""Example
Set the content property.
<smart-button content='Button Label'></smart-button>
Set the content property by using the HTML Element's instance.
const button = document.querySelector('smart-button');
button.content = New Button Label;
Get the content property.
const button = document.querySelector('smart-button');
let content = button.content;
disabledboolean
Determines whether the button is interactive. When enabled ('true'), users can click and interact with the button. When disabled ('false'), the button appears inactive and does not respond to user actions.
Default value
falseExample
Set the disabled property.
<smart-button disabled></smart-button>
Set the disabled property by using the HTML Element's instance.
const button = document.querySelector('smart-button');
button.disabled = false;
Get the disabled property.
const button = document.querySelector('smart-button');
let disabled = button.disabled;
innerHTMLstring
Updates the contents of the element by setting its inner HTML to the specified value. This replaces all existing child elements and text within the element with the provided HTML markup. Use caution when inserting user-generated content to avoid security risks such as cross-site scripting (XSS).
Default value
""""Example
Set the innerHTML property.
<smart-button inner-h-t-m-l='Button Label'></smart-button>
Set the innerHTML property by using the HTML Element's instance.
const button = document.querySelector('smart-button');
button.innerHTML = 'New Button Label';
Get the innerHTML property.
const button = document.querySelector('smart-button');
let innerHTML = button.innerHTML;
unlockKeystring
Handles the retrieval or assignment of the 'unlockKey', a unique value required to authorize and unlock access to the product's features or content.
Default value
""Example
Set the unlockKey property.
<smart-button unlock-key=''></smart-button>
Set the unlockKey property by using the HTML Element's instance.
const button = document.querySelector('smart-button');
button.unlockKey = '1111-2222-3333-4444-5555';
Get the unlockKey property.
const button = document.querySelector('smart-button');
let unlockKey = button.unlockKey;
localestring
Specifies the language code to use for retrieving or displaying messages. When set, it determines which localized message set from the messages property is used. Getting this property returns the current language code. Typically used for enabling multi-language support within the application.
Default value
"en"Example
Set the locale property.
<smart-button locale='de'></smart-button>
Set the locale property by using the HTML Element's instance.
const button = document.querySelector('smart-button');
button.locale = 'fr';
Get the locale property.
const button = document.querySelector('smart-button');
let locale = button.locale;
localizeFormatFunctionfunction | null
A callback function that allows you to define or modify the formatting of messages returned by the Localization Module. Use this callback to customize how localized messages are structured or displayed before they are delivered to your application.
Example
Set the localizeFormatFunction property.
<smart-button localize-format-function='function(defaultMessage, message, messageArguments){return '...'}'></smart-button>
Set the localizeFormatFunction property by using the HTML Element's instance.
const button = document.querySelector('smart-button');
button.localizeFormatFunction = function(defaultMessage, message, messageArguments){return '...'};
Get the localizeFormatFunction property.
const button = document.querySelector('smart-button');
let localizeFormatFunction = button.localizeFormatFunction;
messagesobject
Defines or retrieves an object containing localized strings for the widget's user interface. This property allows you to customize text displayed by the widget for different languages and regions, and works in conjunction with the locale property to ensure proper localization.
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."
}
Example
Set the messages property.
<smart-button 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-button>
Set the messages property by using the HTML Element's instance.
const button = document.querySelector('smart-button');
button.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."}};
Get the messages property.
const button = document.querySelector('smart-button');
let messages = button.messages;
namestring
Defines or retrieves the name attribute of the element. The name attribute uniquely identifies form elements when submitting data through an HTML form, allowing the server to associate input values with their corresponding fields. This attribute is essential for processing form data correctly.
Default value
""""Example
Set the name property.
<smart-button name='Name'></smart-button>
Set the name property by using the HTML Element's instance.
const button = document.querySelector('smart-button');
button.name = 'New Name';
Get the name property.
const button = document.querySelector('smart-button');
let name = button.name;
readonlyboolean
If the custom element is set to readonly, users will not be able to modify its value or content through direct interaction (such as typing, selecting, or dragging). However, the element may still be focusable and its value can be changed programmatically via scripts. User-initiated actions that would normally alter its state are disabled.
Default value
falseExample
Set the readonly property.
<smart-button readonly></smart-button>
Set the readonly property by using the HTML Element's instance.
const button = document.querySelector('smart-button');
button.readonly = false;
Get the readonly property.
const button = document.querySelector('smart-button');
let readonly = button.readonly;
rightToLeftboolean
Gets or sets a value that determines whether the element's alignment supports right-to-left (RTL) text direction, which is typically used by languages such as Arabic or Hebrew. When enabled, the element is properly aligned to display content for RTL locales.
Default value
falseExample
Set the rightToLeft property.
<smart-button right-to-left></smart-button>
Set the rightToLeft property by using the HTML Element's instance.
const button = document.querySelector('smart-button');
button.rightToLeft = true;
Get the rightToLeft property.
const button = document.querySelector('smart-button');
let rightToLeft = button.rightToLeft;
themestring
Specifies the visual theme applied to the element, which controls its overall appearance, including colors, fonts, and styling. This property allows you to select a predefined look and feel for the element.
Default value
""Example
Set the theme property.
<smart-button theme='blue'></smart-button>
Set the theme property by using the HTML Element's instance.
const button = document.querySelector('smart-button');
button.theme = 'red';
Get the theme property.
const button = document.querySelector('smart-button');
let theme = button.theme;
typestring
Specifies or retrieves the button's type attribute, which determines the button's behavior—such as "submit" to submit a form, "reset" to reset form fields, or "button" for a general-purpose clickable button.
Default value
"Reset"Example
Set the type property.
<smart-button type='submit'></smart-button>
Set the type property by using the HTML Element's instance.
const button = document.querySelector('smart-button');
button.type = 'reset';
Get the type property.
const button = document.querySelector('smart-button');
let type = button.type;
valuestring
Sets or retrieves the button's value attribute, which typically defines the text displayed on the button or the value submitted when the button is used in a form.
Default value
""Example
Set the value property.
<smart-button value='Value'></smart-button>
Set the value property by using the HTML Element's instance.
const button = document.querySelector('smart-button');
button.value = 'New value';
Get the value property.
const button = document.querySelector('smart-button');
let value = button.value;
unfocusableboolean
When set to true, this property prevents the element from receiving keyboard focus, making it impossible for users to select the element using the Tab key or other navigation methods.
Default value
falseExample
Set the unfocusable property.
<smart-button unfocusable></smart-button>
Set the unfocusable property by using the HTML Element's instance.
const button = document.querySelector('smart-button');
button.unfocusable = false;
Get the unfocusable property.
const button = document.querySelector('smart-button');
let unfocusable = button.unfocusable;
Events
clickCustomEvent
The click event is triggered based on the selected clickMode, meaning the event behavior will vary depending on the current setting of the clickMode property.
- Bubbles Yes
- Cancelable No
- Interface CustomEvent
- Event handler property onClick
Arguments
evCustomEvent
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.
Example
Set up the event handler of click event.
const button = document.querySelector('smart-button'); button.addEventListener('click', function (event) { // event handling code goes here. })
CSS Variables
--smart-button-text-transformvar()
Default value
"uppercase"Controls the capitalization of button's text. Could be set as uppercase/lowercase/capitalize.
--smart-button-paddingvar()
Default value
"8px 16px"Sets button's paddings.
--smart-button-large-paddingvar()
Default value
"10px 16px"Sets large button's paddings.
--smart-button-large-font-sizevar()
Default value
"18px"Sets large button's font size.
--smart-button-small-paddingvar()
Default value
"5px 10px"Sets small button's paddings.
--smart-button-small-font-sizevar()
Default value
"12px"Sets small button's font size.
--smart-button-very-small-paddingvar()
Default value
"1px 5px"Sets very small button's paddings.
--smart-button-very-small-font-sizevar()
Default value
"12px"Sets very small button's font size.
--smart-button-flat-colorvar()
Default value
"var(--smart-background-color)"The color of the flat button.
--smart-button-outlined-colorvar()
Default value
"var(--smart-background-color)"The color of the outlined button.
--smart-button-outlined-bordervar()
Default value
"var(--smart-border)"The border of the outlined button.