function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ishan K SharmaIshan K Sharma 

Lightning Form Does not Display Lightning Experience

Hi,

Below is a simple example of lightnng form  but it is not showing lightning experience. CSS is not working. Do i need to call Lightning CSS style sheet all the time in every lightning component? Or i am missing something else ?
 
<aura:component>
    <div class="slds-p-bottom_large slds-p-left_large" style="width:500px">
        <lightning:recordEditForm aura:id="recordViewForm"
                                     recordId="0036F00002mr8eC"
                                     objectApiName="Contact">
            <lightning:messages />
            <lightning:inputField fieldName="FirstName" />
            <lightning:inputField fieldName="LastName" />
            <lightning:inputField fieldName="Birthdate" />
            <lightning:inputField fieldName="Phone" />
            <!--Picklist-->
            <lightning:inputField fieldName="Level__c" />
            <lightning:button aura:id="submit" type="submit" label="Update record" class="slds-m-top_medium" />
            </lightning:recordEditForm>
    </div>
</aura:component>

User-added image
NagendraNagendra (Salesforce Developers) 

Hi Ishan,

Sorry for this issue you are facing.

Style sheets can be created in different ways.

You can create a style sheet which works specifically for one component and also you can create a stylesheet which you can use across multiple lightning components and applications.

If you need to use your style sheet to multiple lightning components or lighting application, then it’s always recommended to define a common style sheet in a separate file with extension as .css. Upload this external CSS file as a static resource and it will be included in Lightning component using
<ltng:require styles=”{! $Resource.staticResourceFileName}”/>  tag.

Sample CSS file is below:

demoCss.css (external CSS file):

/*external css file with .css file extension */
 p{
     font-size:20px;
     color:red;
     background-color:black;
   }
  
  .divStyle{
       background-color:lightgreen;
       color:white;
       padding:20px; 
     }
User-added image

YourComponent.cmp:

<aura:component>
<ltng:require styles="{!$Resource.demoCss}"/>
    <div class="slds-p-bottom_large slds-p-left_large" style="width:500px">
        <lightning:recordEditForm aura:id="recordViewForm"
                                     recordId="003R00000000000000"
                                     recordTypeId="012R00000000000000"
                                     objectApiName="Contact">
            <lightning:messages />
            <lightning:inputField fieldName="FirstName" />
            <lightning:inputField fieldName="LastName" />
            <lightning:inputField fieldName="Birthdate" />
            <lightning:inputField fieldName="Phone" />
            <!--Picklist-->
            <lightning:inputField fieldName="Level__c" />
            <lightning:button aura:id="submit" type="submit" label="Update record" class="slds-m-top_medium" />
            </lightning:recordEditForm>
</div>
</aura:component>
For more information on using style sheets in different ways, I would suggest you please refer to below blog post which is really helpful. Hope this helps.

Kindly mark this as solved if the reply was helpful so that it gets removed from the unanswered queue which results in helping others who are encountering a similar issue.

Thanks,
Nagendra