PasswordTextBox CSS Styling

Smart.PasswordTextBox element represents an password input, supported password strength validation.

Required files

Smart.PasswordTextBox requires the following scripts to be referenced on a page in order for the custom element to be successfully registered and to work correctly:

  • 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.textbox.js -- this file defines the functionality of the Smart.TextBox custom element. Smart.PasswordTextBox inherits Smart.TextBox custom element.
  • smart.tooltip.js -- this file defines the functionality of the SmartTooltip custom element.
  • smart.passwordtextbox.js -- this file defines the functionality of the Smart.PasswordTextBox custom element.

Smart.PasswordTextBox also requires the following style sheet in order to be displayed correctly.

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

Initialization

To initialize (instantiate) a Smart.PasswordTextBox custom element, insert the following tag in an HTML page:

<smart-password-text-box></smart-password-text-box>

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

<smart-password-text-box show-password-strength></smart-password-text-box>

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-password-text-box');

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 showPasswordStrength = customElement.showPasswordStrength;

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

customElement.showPasswordStrength = true;

Calling methods

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

let customElement = document.querySelector('smart-password-text-box');

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

Here is an example showing how to call a method:

customElement.reset();

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.PasswordTextBox:

  • smart-password-text-box - 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.
    • .smart-inner-container - an additional container, separated the input and password icon from the other elements.
      • INPUT element - an HTML Input element of type "password" used for the user input.
      • .smart-password-icon - an HTML Span element used to display the show/hide password icon.
    • .smart-hint - an HTML Span element used to hold the hint below the element.
    • smart-tooltip - a tooltip used about password strength visualization.

CSS variables

Smart.PasswordTextBox uses the following CSS variables:

  • --smart-text-box-default-width - used to set the default width of the element. Default value is 200px.
  • --smart-text-box-default-height - used to set the default height of the element. Default value is 30px.