RadioButton CSS Styling

Smart.RadioButton is a simple HTML radio button that offers the functionality to be checked or not(depending on wheather there's another radio button in the same group).

Required files

The Smart.RadioButton element requires the following file references to be placed on a web page in order for the custom element to be successfully registered and properly working:

  • smart.element.js -- this is the base file that defines the common architecture of all Smart custom elements. It is part of the repository ni-kismet/smart-element.
  • smart.button.js -- this is the base button class. Radio button inherits it.
  • smart.radiobutton.js -- this file defines the functionality of the Smart.RadioButton custom element.

Smart.RadioButton also requires the following style sheets in order to be displayed correctly.

  • smart.base.css -- the base style sheet file.


To create an instance of a Smart.RadioButton custom element, insert the following tag in an HTML page:


To set properties of the custom element initially, do so by setting the respective attributes of the tag, e.g.:

<smart-radio-button checked name="radioButton1" group-name="one" enable-container-click></smart-radio-button>

Getting and setting properties dynamically

Before accessing the custom element's API in JavaScript, the custom element's instance has to be retrieved:

let customElement = document.querySelector('smart-radio-button');

Properties are represented as members of the custom element's instance object and can be accessed as such.

Here is an example showing how to get a property dynamically:

let checked = customElement.checked;

Here is an example showing how to set a property dynamically:

customElement.checked = true;

Styling (CSS API)

Smart HTML Elements use a pair of css files - smart.base.css and smart.[theme name].css. The base stylesheet creates the styles related to the element's layout like margin, padding, border-width, position. The second CSS file applies the HTML Element's colors, fonts, borders and backgrounds. The smart.base.css should be included before the second CSS file.

CSS selectors

The following CSS selectors can be used to style Smart.RadioButton:

  • smart-radio-button - the element itself. Can be used to set width and height for the whole element.
    • .smart-container - the container that holds all of the internals of the element. Shoudn't be used for styling.
    • .smart-label - an HTML Span element used to hold the label above the element.
    • INPUT element - an HTML Input element used for the user input.
    • .smart-hint - an HTML Span element used to hold the hint below the element.

CSS variables

Smart.RadioButton uses the following CSS variables:

  • --smart-radio-button-default-size - used to set the default width and height of the element's input. Default value is 10px.