How to apply css to inner elements of lightning input lwc?
I am trying to add border colour to the lightning-input lwc component. First when i tried the below css
value="test" key={f.Id} data-id={f.Id} variant="label-inline" label="test" title="test">
<button class="slds-button slds-button_brand">Submit</button>
enter image description here
The issue here is I want the border to be exact on the input not around it. Please let me know how it is possible for lightning-input lwc.
To apply css to inner elements of lightning input lwc -
we have to override CSS :
Create a CSS file and add in static resource
File Content :
.customInput .slds-input{
border-colour: red;
}
Import That static resource file in your component
import { loadStyle } from 'lightning/platformResourceLoader';
import CUSTOMCSS from '@salesforce/resourceUrl/{yourfileName}';
a) Define variable like : isCssLoaded = false;
Call it in reRenderCallback
renderedCallback(){
if(this.isCssLoaded) return
this.isCssLoaded = true;
loadStyle(this,CUSTOMCSS).then(()=>{
console.log('loaded');
})
.catch(error=>{
console.log('error to load');
});
}
Its look like this