RadioButton JAVASCRIPT UI Component API

RadioButton Javascript API

Class

RadioButton

The Radio Button component lets you add a radio button and assign it to a radio group. Users can select only one radio button at a time within a radio group

Selector

smart-radio-button

Properties

AanimationSets or gets the animation mode. Animation is disabled when the property is set to 'none'
CcheckedSets or gets the check state.
CcheckModeSets or gets the part that toggles the element.
CclickModeSets the click mode of the radio button.
DdisabledEnables or disables the ratio button.
GgroupNameSets or gets the widget's group name.
IinnerHTMLSets or gets the widget's innerHTML.
LlocaleSets or gets the language. Used in conjunction with the property messages.
LlocalizeFormatFunctionCallback, related to localization module.
MmessagesSets an object with string values, related to the different states of passwords strength.
NnameSets or gets the widget's name.
RreadonlyIf the custom element is readonly, it cannot be interacted with.
RrightToLeftSets or gets the value indicating whether the element is aligned to support locales using right-to-left fonts.
TthemeDetermines the theme. Theme defines the look of the element
UunfocusableIf is set to true, the element cannot be focused.
VvalueSets or gets the widget's value.

Events

CchangeThis event is triggered when the widget is checked/unchecked.
CcheckValueThis event is triggered when the widget is checked.
UuncheckValueThis event is triggered when the widget is unchecked.

Properties

animation"none" | "simple" | "advanced"

Sets or gets the animation mode. Animation is disabled when the property is set to 'none'

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-radio-button animation='none'></smart-radio-button>

Set the animation property by using the HTML Element's instance.

 const radiobutton = document.querySelector('smart-radio-button');
 radiobutton.animation = 'simple';

Get the animation property.

 const radiobutton = document.querySelector('smart-radio-button');
 let animation = radiobutton.animation;

checkedboolean

Sets or gets the check state.

Default value

false

Example

Set the checked property.

 <smart-radio-button checked></smart-radio-button>

Set the checked property by using the HTML Element's instance.

 const radiobutton = document.querySelector('smart-radio-button');
 radiobutton.checked = false;

Get the checked property.

 const radiobutton = document.querySelector('smart-radio-button');
 let checked = radiobutton.checked;

checkMode"both" | "input" | "label"

Sets or gets the part that toggles the element.

Default value

"both"

Example

Set the checkMode property.

 <smart-radio-button check-mode='input'></smart-radio-button>

Set the checkMode property by using the HTML Element's instance.

 const radiobutton = document.querySelector('smart-radio-button');
 radiobutton.checkMode = 'label';

Get the checkMode property.

 const radiobutton = document.querySelector('smart-radio-button');
 let checkMode = radiobutton.checkMode;

clickMode"hover" | "press" | "release" | "pressAndRelease"

Sets the click mode of the radio button.

Default value

"release"

Example

Set the clickMode property.

 <smart-radio-button click-mode='press'></smart-radio-button>

Set the clickMode property by using the HTML Element's instance.

 const radiobutton = document.querySelector('smart-radio-button');
 radiobutton.clickMode = 'pressAndRelease';

Get the clickMode property.

 const radiobutton = document.querySelector('smart-radio-button');
 let clickMode = radiobutton.clickMode;

disabledboolean

Enables or disables the ratio button.

Default value

false

Example

Set the disabled property.

 <smart-radio-button disabled></smart-radio-button>

Set the disabled property by using the HTML Element's instance.

 const radiobutton = document.querySelector('smart-radio-button');
 radiobutton.disabled = false;

Get the disabled property.

 const radiobutton = document.querySelector('smart-radio-button');
 let disabled = radiobutton.disabled;

groupNamestring

Sets or gets the widget's group name.

Default value

""""

Example

Set the groupName property.

 <smart-radio-button group-name='Group'></smart-radio-button>

Set the groupName property by using the HTML Element's instance.

 const radiobutton = document.querySelector('smart-radio-button');
 radiobutton.groupName = 'New Group';

Get the groupName property.

 const radiobutton = document.querySelector('smart-radio-button');
 let groupName = radiobutton.groupName;

innerHTMLstring

Sets or gets the widget's innerHTML.

Default value

""""

Example

Set the innerHTML property.

 <smart-radio-button inner-h-t-m-l='Radio Button Label'></smart-radio-button>

Set the innerHTML property by using the HTML Element's instance.

 const radiobutton = document.querySelector('smart-radio-button');
 radiobutton.innerHTML = 'New Radio Button Label';

Get the innerHTML property.

 const radiobutton = document.querySelector('smart-radio-button');
 let innerHTML = radiobutton.innerHTML;

localestring

Sets or gets the language. Used in conjunction with the property messages.

Default value

"en"

Example

Set the locale property.

 <smart-radio-button locale='de'></smart-radio-button>

Set the locale property by using the HTML Element's instance.

 const radiobutton = document.querySelector('smart-radio-button');
 radiobutton.locale = 'fr';

Get the locale property.

 const radiobutton = document.querySelector('smart-radio-button');
 let locale = radiobutton.locale;

localizeFormatFunctionfunction | null

Callback, related to localization module.

Example

Set the localizeFormatFunction property.

 <smart-radio-button localize-format-function='function(){return '...'}'></smart-radio-button>

Set the localizeFormatFunction property by using the HTML Element's instance.

 const radiobutton = document.querySelector('smart-radio-button');
 radiobutton.localizeFormatFunction = function(){return '...'};

Get the localizeFormatFunction property.

 const radiobutton = document.querySelector('smart-radio-button');
 let localizeFormatFunction = radiobutton.localizeFormatFunction;

messagesobject

Sets an object with string values, related to the different states of passwords strength.

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-radio-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-radio-button>

Set the messages property by using the HTML Element's instance.

 const radiobutton = document.querySelector('smart-radio-button');
 radiobutton.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 radiobutton = document.querySelector('smart-radio-button');
 let messages = radiobutton.messages;

namestring

Sets or gets the widget's name.

Default value

""""

Example

Set the name property.

 <smart-radio-button name='Name'></smart-radio-button>

Set the name property by using the HTML Element's instance.

 const radiobutton = document.querySelector('smart-radio-button');
 radiobutton.name = 'New Name';

Get the name property.

 const radiobutton = document.querySelector('smart-radio-button');
 let name = radiobutton.name;

readonlyboolean

If the custom element is readonly, it cannot be interacted with.

Default value

false

Example

Set the readonly property.

 <smart-radio-button readonly></smart-radio-button>

Set the readonly property by using the HTML Element's instance.

 const radiobutton = document.querySelector('smart-radio-button');
 radiobutton.readonly = false;

Get the readonly property.

 const radiobutton = document.querySelector('smart-radio-button');
 let readonly = radiobutton.readonly;

rightToLeftboolean

Sets or gets the value indicating whether the element is aligned to support locales using right-to-left fonts.

Default value

false

Example

Set the rightToLeft property.

 <smart-radio-button right-to-left></smart-radio-button>

Set the rightToLeft property by using the HTML Element's instance.

 const radiobutton = document.querySelector('smart-radio-button');
 radiobutton.rightToLeft = true;

Get the rightToLeft property.

 const radiobutton = document.querySelector('smart-radio-button');
 let rightToLeft = radiobutton.rightToLeft;

themestring

Determines the theme. Theme defines the look of the element

Default value

""

Example

Set the theme property.

 <smart-radio-button theme='blue'></smart-radio-button>

Set the theme property by using the HTML Element's instance.

 const radiobutton = document.querySelector('smart-radio-button');
 radiobutton.theme = 'red';

Get the theme property.

 const radiobutton = document.querySelector('smart-radio-button');
 let theme = radiobutton.theme;

unfocusableboolean

If is set to true, the element cannot be focused.

Default value

false

Example

Set the unfocusable property.

 <smart-radio-button unfocusable></smart-radio-button>

Set the unfocusable property by using the HTML Element's instance.

 const radiobutton = document.querySelector('smart-radio-button');
 radiobutton.unfocusable = false;

Get the unfocusable property.

 const radiobutton = document.querySelector('smart-radio-button');
 let unfocusable = radiobutton.unfocusable;

valuestring

Sets or gets the widget's value.

Default value

""""

Example

Set the value property.

 <smart-radio-button value='Value'></smart-radio-button>

Set the value property by using the HTML Element's instance.

 const radiobutton = document.querySelector('smart-radio-button');
 radiobutton.value = 'New Value';

Get the value property.

 const radiobutton = document.querySelector('smart-radio-button');
 let value = radiobutton.value;

Events

changeCustomEvent

This event is triggered when the widget is checked/unchecked.

  • Bubbles Yes
  • Cancelable No
  • Interface CustomEvent
  • Event handler property onChange

Arguments

evCustomEvent
ev.detailObject
ev.detail.value - A boolean value indicating the new state of the button ( checked or not ).
ev.detail.oldValue - A boolean value indicating the previous state of the button ( checked or not ).
ev.detail.changeType - A string flag indicating whether the change event was triggered via API or an event.

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 change event.

const radiobutton = document.querySelector('smart-radio-button');
radiobutton.addEventListener('change', function (event) {
    const detail = event.detail,
        value = detail.value,
        oldValue = detail.oldValue,
        changeType = detail.changeType;

	// event handling code goes here.
})

checkValueCustomEvent

This event is triggered when the widget is checked.

  • Bubbles Yes
  • Cancelable No
  • Interface CustomEvent
  • Event handler property onCheckValue

Arguments

evCustomEvent
ev.detailObject
ev.detail.changeType - A string flag indicating whether the change event was triggered via API or an event.

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 checkValue event.

const radiobutton = document.querySelector('smart-radio-button');
radiobutton.addEventListener('checkValue', function (event) {
    const detail = event.detail,
        changeType = detail.changeType;

	// event handling code goes here.
})

uncheckValueCustomEvent

This event is triggered when the widget is unchecked.

  • Bubbles Yes
  • Cancelable No
  • Interface CustomEvent
  • Event handler property onUncheckValue

Arguments

evCustomEvent
ev.detailObject
ev.detail.changeType - A string flag indicating whether the change event was triggered via API or an event.

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 uncheckValue event.

const radiobutton = document.querySelector('smart-radio-button');
radiobutton.addEventListener('uncheckValue', function (event) {
    const detail = event.detail,
        changeType = detail.changeType;

	// event handling code goes here.
})

CSS Variables

--smart-radio-button-default-sizevar()

Default value

"calc(1px + 1/2 * var(--smart-editor-height))"

Default size for the radio button.