I have a simple LWC component where I want users to define CSS using designer attributes. However, it doesn't seem to pick it when I load it on the page even though console logs are picking up the right value. Please help.
Here is my code: HTML:
<template>
<div style={divStyle}>
<span style={fontStyle}>{textToDisplay}</span>
</div>
</template>
JS file:
import { LightningElement, api } from 'lwc';
export default class GenericCard extends LightningElement {
@api textToDisplay;
@api textColor;
@api backgroundColor;
get divStyle() {
console.log('User entered background color: ' + this.backgroundColor);
return 'background:${this.backgroundColor};color:${this.textColor};text-align:center;padding:6px;';
}
get fontStyle() {
return 'color:${this.textColor}';
}
}
I can see text align and padding but not the background color for the div or the font color.