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
suji srinivasansuji srinivasan 

backgroundcolour to LWC lightning datatable using css

Hi, background colour is not changing only text colour is getting changed for my lightning data table
.css:
tabletitle{
    color: var(--light-theme-text-color,#e06000);
    font-weight: bold;
}
.
.tablecss {
 background-color: var(--light-theme-backgroud-color, lightcyan);
    color: var(--light-theme-text-color, darkblue);
 
    font-weight: bold;
}
html:
<template>
    <template if:true={isSpinner}>
        <div class="spinner">
            <lightning-spinner alternative-text="Loading" size="medium"></lightning-spinner>
        </div>
    </template>
   
    <lightning-card title="My Rewards" class="tabletitle">
        <div class="tablecss">
        <lightning-datatable data={salaryList} columns={cols} key-field="Id" >
       
        </lightning-datatable> </div>
    </lightning-card>
</template>

thanks in advance
Best Answer chosen by suji srinivasan
PriyaPriya (Salesforce Developers) 
Hi Suji,

Kindly refer this example for changing the background color of data table :- 

https://www.salesforcetroop.com/datatable_styling_in_lwc
 

Kindly mark it as the best answer if it works for you.

 

Thanks & Regards,

Priya Ranjan