1

EDIT: This is a duplicate question. Answer here if you have a good answer: lightning-input type date, hide date format below the field

With the Winter '25 release there is an update that adds the expected format for a date or datetime below it. This is supposed to help the user enter a date when not using the date picker.

e.g.

enter image description here

Is there a way to get rid of this?

I've had a look at the HTML for this div and it uses the class slds-form-element__help which doesn't have a styling hook, and I can't find any configuration on the lighting-input component.

Winter '25 Release Information: https://help.salesforce.com/s/articleView?id=release-notes.rn_lc_base_component_accessibility.htm&release=252&type=5

Improve Accessibility with Base Lightning Components

The lightning-input component now displays the expected date format below the text input field for input types date and datetime. This informative text helps users who enter the date in the text field instead of selecting from the date picker. Previously, users were informed of the expected format in an error message if they entered the date incorrectly.

5
  • 1
    This seems like a duplicate question from here salesforce.stackexchange.com/questions/425598/…
    – prem22
    Commented Sep 3 at 6:51
  • You're right. I didn't find that question when I asked this. I can't delete or close this question though.
    – Nick C
    Commented Sep 3 at 7:27
  • I could not find the question as well to mark this as duplicate. Might be because I posted that question?
    – prem22
    Commented Sep 3 at 7:39
  • I think it's because it doesn't have an accepted answer.
    – Nick C
    Commented Sep 3 at 23:37
  • 1
    Please use below to track the changes as new feature has been requested to hide the formatted text. issues.salesforce.com/issue/a028c00000zLnlr
    – Amit
    Commented Sep 6 at 15:26

3 Answers 3

1

enter image description here

You can get rid of the expected date format under the DateTime/Date fields by overriding the CSS using the LoadStyle method as explained below:

Step 1: Upload Static Resource

  1. Create a RemoveDateFormatStyle.css file using Notepad++
  2. RemoveDateFormatStyle.css should contain the below CSS:
        .date-format-hide .slds-form-element__help{
            display: none;
        }
        .date-format-hide .slds-show{
            display:block;
        }
  1. Upload it as a Static Resource in SF and make it public.

Step 2: Add a class to your LWC Input Date Element

  1. Add a class to your input element of type date which should hide this expected date format.

<lightning:input class="date-format-hide" type="date" name="input1" label="Enter a date" />

Step 3: LWC LoadStyle

  1. In your JS file of your LWC component, import the below two lines:

    import { loadStyle } from 'lightning/platformResourceLoader';
    import styles from '@salesforce/resourceUrl/RemoveDateFormatStyle';
  1. Use RenderedCallBack to load your customized style into the DOM.

    renderedCallback(){
         Promise.all([
             loadStyle(this, styles) //specified filename
         ]).then(() => {
             window.console.log('Files loaded.');
         }).catch(error => {
             window.console.log("Error " + error.body.message);
         });
     }

Hope this helps!!

Final Result: enter image description here

2
  • Won't this result in that div always being hidden? It's the same div that displays any validation error messages, so this would break other things.
    – Nick C
    Commented Sep 3 at 4:55
  • Yes, @NickC absolutely! But the error messages on lightning-input has another class called slds-show, so if we override it back to display:block, I think it should work fine, but let me know your thoughts on this.
    – Jayanth G
    Commented Sep 3 at 5:28
0

Use the below in rendered callback to remove that label,

html-

<lightning-input required type="date" label="Date of Birth" data-field="Date_of_Birth__c" value={value}></lightning-input>

js-

loaded = false
renderedCallback() {
 if(!this.loaded) {
  let style = document.createElement('style')
  style.innerText = 'div[class=slds-form-element__help]{display:none;}'
  this.template.querySelector("lightning-input[data-field='Date_of_Birth__c']").appendChild(style)
  this.loaded = true
 }
}
0

You can get rid of the expected date format under the DateTime/Date hook --lwc-fontSize2: 0rem; enter image description here

enter image description here

enter image description hereenter image description here

1
  • It remove this text but in adition also add 0rem font size on date selector as well loking into another way Commented Sep 9 at 19:54

You must log in to answer this question.

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