In the composition navigator, select the Widget Explorer tab.
This composition contains three widgets, but for this quick start, you'll look at the text widget, which in the composition is called lowerText.
Composition script
Now that you have located the composition's text widget, learn how to use the text widget’s HTML feature to style text and set a background color in the Lower composition script.
You can also copy and paste the composition script below into your own compositions.
Lower script
(function() { const HTML_TEMPLATE = '<html><span style="background:{{background-color}}; padding: 0px {{padding-right}}px 0px {{padding-left}}px">{{firstname}} <b>{{secondname}}</b></span></html>';
// convert color JSON to CSS rgba()constparseColor=function(color) {constcolorRgba=`rgba(${color.r}, ${color.g}, ${color.b}, ${color.a})`;// console.log("colorRgba =", colorRgba);return colorRgba; }return {init:function(comp, context) {// get reference to the fullname widgetconstwiLowerText=comp.findWidget("lowerText")[0];/**********************************************************************/// we define a function to update the compositionfunctionupdateComposition() {// get control node payload as JSON objectconstp=comp.getPayload2();console.log(p);constcolorRgba=parseColor(p["Background Color"]);// build HTML text.let htmlText =HTML_TEMPLATE.replace(/{{background-color}}/gi, colorRgba); htmlText =htmlText.replace(/{{padding-right}}/gi, p["Padding Right"]); htmlText =htmlText.replace(/{{padding-left}}/gi, p["Padding Left"]); htmlText =htmlText.replace(/{{firstname}}/gi, p["Firstname"]); htmlText =htmlText.replace(/{{secondname}}/gi, p["Lastname"]);// update fullname textwiLowerText.setPayload({"text": htmlText }); }/**********************************************************************/// we listen to payload_changed eventscomp.addListener('payload_changed', (event, msg, e) => {updateComposition();e.stopPropagation(); });/**********************************************************************/// update the composition when loading the output URLupdateComposition(); },close:function(comp, context) {} };})();