Skip to content

Password

Password components are Input Fields that allow the user to enter hidden string chains, commonly used for sensitive information.

password.ts
import { golemForm } from '@golemui/gui-shared';
export default golemForm().create({
form: [
{
kind: 'input',
type: 'password',
path: 'password',
label: 'Password',
},
],
});

Use these props to customize your Password component.

proptypedescription
placeholderstringA placeholder text to display when the password input has no value
hintstringA description to display below the password input
iconstringA css class to display an icon inside the input
showPasswordIconstringIcon indicating the state to show the password (e.g. eye icon)
hidePasswordIconstringIcon indicating the state to hide the password (e.g. eye-slash icon)
showPasswordLabelstringLabel text for the show password toggle, visible if no icon is set
hidePasswordLabelstringLabel text for the hide password toggle, visible if no icon is set
autocompletestring'on', 'off', or a space-separated list of W3C autofill tokens

Use the property placeholder to add a placeholder.

password.ts
import { golemForm } from '@golemui/gui-shared';
export default golemForm().create({
form: [
{
kind: 'input',
type: 'password',
path: 'password',
label: 'Password',
props: {
placeholder: 'Enter your secure password',
},
},
],
});

Use the property hint to add a description.

password.ts
import { golemForm } from '@golemui/gui-shared';
export default golemForm().create({
form: [
{
kind: 'input',
type: 'password',
path: 'password',
label: 'Password',
props: {
hint: 'Must be at least 8 characters long.',
},
},
],
});

Use the property icon to add an icon to the password. The value of icon represents a set of CSS classes separated by spaces. The icon is displayed on the left by default. The component also has built-in icons and labels to toggle password visibility.

password.ts
import { golemForm } from '@golemui/gui-shared';
export default golemForm().create({
form: [
{
kind: 'input',
type: 'password',
path: 'password',
label: 'Password',
props: {
icon: 'fas fa-lock',
},
},
],
});

Passwords can be styled as explained in the Styling Guide.

Following you will find a list with the CSS Variables and a quick description of what you will style.

CSS VariableDescription
--gui-space-gap--innerLabel gap and margin bottom
--gui-paddingInput padding
--gui-color-borderInput border color
--gui-radiusInput radius
--gui-color-bgInput background color
--gui-color-fgInput text color
--gui-color-primaryInput border color and outline on focus
--gui-color-errorInput border color when invalid
--gui-space-gapIcon left padding
--gui-icon-space-gapIcon right padding
--gui-font-size--smallHint font size
--gui-color-fg--secondaryHint font color
--gui-text-defaultEye icon toggle color

This is the anatomy of the Password Component in case you want to use your CSS styles.

password-anatomy.html
<gui-password>
<label for="fieldUid">
Label
<div class="gui-password__hint" id="fieldUid_hint">Hint</div>
</label>
<div class="gui-widget">
<input
type="password"
id="fieldUid"
class="gui-password--icon"
placeholder="Custom placeholder"
aria-required="true"
aria-describedby="fieldUid_hint"
/>
<span class="gui-password__icon"></span>
<button
class="gui-password__toggle fas fa-eye"
type="button"
tabindex="-1"
>
<span>Show</span>
</button>
</div>
</gui-password>