You need to sign in to do that
Don't have an account?

How to style lightning:outputFields in a recordViewForm?
I have the following component for my Community dispaying specific fields pulled from the user's Account object. How can I style the lightning:outputFields? I have wrapped the lightning:outputFields in a Div wrapper and tried to style that but doesn't work. Any suggestions?
<aura:component controller="AccountDisplayController" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" > <aura:attribute name="accountId" type="string" default = '0010r00000BtdLoAAJ'/> <aura:handler name="init" value="{!this}" action="{!c.init}" /> <aura:if isTrue="{! not( empty( v.accountId ) ) }"> <div class="billingtitle"><h1>Billing Information</h1></div> <lightning:recordViewForm recordId="{!v.accountId}" objectApiName="Account"> <div class="slds-grid"> <div class="slds-col slds-size_1-of-2"> <lightning:outputField fieldName="Agreement_Date__c"/> <lightning:outputField fieldName="Renewal_Date__c"/> </div> <div class="slds-col slds-size_1-of-2"> <lightning:outputField fieldName="Product_Service1__c"/> <lightning:outputField fieldName="Number_of_Seats_Purchased__c"/> </div> </div> </lightning:recordViewForm> </aura:if> </aura:component>
The first one styles the LABEL and the second one styles the contents.
If you want to switch it up and display record data a different way, you could try this
All Answers
Controller:
Then in your STYLE element, you can adjust it's style:
My CSS: I tried .THIS.number-of-seats as well and it didn't work.
My Helper:
I've been able to style a div outside the lightning:recordViewForm wrapper but when I try to style those to lightning output fields, no success.
The first one styles the LABEL and the second one styles the contents.
If you want to switch it up and display record data a different way, you could try this
Hi Ryan,
I have the similar requirement but, I don't have any helper class or any server calls etc. Here I am using record view form and output field tag. I want to make the record's name bold.
Here is the code:
And the snap of the output. Here I highlighted the area which I want to turn it bold. Please help me out on this.
DIV:
we can do by wrapping in class
<div class="boldClass">
<lightning-output-field field-name={field1} field-class="boldClass"> </lightning-output-field>
</div>
in css :
.boldClass{
--lwc-inputStaticFontWeight: bold !important;
}