I am using lightning-record-edit-form to design a form layout for creating records. In that form, for one of the field, I want to mask the characters while typing. But looks like there is no such 'type' attribute where I can specify the type='password' for this field. Is there any way where I can mask all the characters while typing and send the original unmasked value to the server for the record insertion?

1 Answer 1


In base component value is masked after save as mentioned in the documentation

To mask the value while typing you can add CSS property -webkit-text-security: disc to mask input.


    <lightning-card title="Account Edit">
        <lightning-record-edit-form object-api-name="Account">
            <lightning-input-field field-name="Name">
            <lightning-input-field field-name="test_password__c" class="masked">

            <lightning-button class="slds-m-top_small" type="submit" label="Create new">


import { LightningElement } from 'lwc';
import { loadStyle } from 'lightning/platformResourceLoader';
import maskedCss from '@salesforce/resourceUrl/masked';

export default class MyComponent extends LightningElement {

    connectedCallback() {
        loadStyle(this, maskedCss);


.masked  .slds-input {
    -webkit-text-security: disc;

I have added CSS inside a static resource because the child components style can not be overridden from outside in lwc because of shadow root.

  • Thank you so much.. It worked...!!!
    – sfdc07
    Mar 15, 2020 at 14:38
  • Since this is a required field, the message which we get 'Complete this field' just below the text box is also getting masked. Would you know how to unmask this message?
    – sfdc07
    Mar 15, 2020 at 15:03
  • I have updated my answer to fix the issue, now I'm adding the CSS from static resource and specifically targeting the text part of input field. Mar 15, 2020 at 15:53
  • 1
    It is working like a charm..... Thank you again...!!!
    – sfdc07
    Mar 15, 2020 at 18:46
  • -webkit-text-security: disc; not working in Firefox Feb 1, 2021 at 14:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .