Password input

Import

Import the settings, the text-input, the password-input and the fields scss files.


@import 'settings-tools/all-settings';
@import 'components/c.text-input';
@import 'components/c.password-input';
@import 'components/c.fields';

Usage

To implement the Password Input in your code, you must therefore use and respect the following HTML structure:


<div class="example">
<div class="mc-field">
<label class="mc-field__label" for="default">Label</label>
<div class="mc-password-input mc-field__element">
<input
type="password"
class="mc-text-input mc-password-input__control"
id="default"
name="default"
/>
<button
type="button"
class="mc-password-input__button"
role="switch"
aria-pressed="false"
>
Show
</button>
</div>
</div>
</div>

States

The various states of the Password Input component are identical to the states implemented for the Field component.

For more information, please read the associated documentation for the MField component.

Behaviour

By default, the HTML <input /> tag in the Password Input component has an type="password" attribute. This attribute is used to hide the text entered by the user inside the field.

In order to make the text entered in the field visible, the type="password" attribute must be replaced by the type="text" attribute dynamically using Javascript.