I want to show default value as 0.0 in lightning:input field on page load.
I don't want it to be a placeholder.
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It only takes a minute to sign up.Sign up to join this community
According to SF documentation, it is possible to be done without placeholder, just put default value in value field:
<lightning:input type="number" name="input2" label="Number field with a predefined value" value="0.0"/>
Check out this playground to get an sample example of Number field with a predefined value in Lightning Web Component.
value property of lightning-input component specifies the value of an input element.
Reference:- Lightning Web Component Input
if you are dealing with Lightning Data service and want to pre-populate the field value of lightning-input-field, You can again use the value property of it to pre-populate.
<lightning-record-edit-form id="recordViewForm" record-id="003R00000000000000" record-type-id="012R00000000000000" object-api-name="Contact"> <lightning-messages></lightning-messages> <lightning-input-field field-name="NumberField__c" value="0.0"> </lightning-input-field> <lightning-button type="submit" label="Update record" class="slds-m-top_medium"> </lightning-button> </lightning-record-edit-form>