Answered

baackgroundColor property for miro.board.widgets.create method


Badge +1

I have the following code to recursively create a custom sticky widget from a CSV inside a web plugin. 

miro.board.widgets.create({
"type": "sticker",
"style": {
"backgroundColor": "#ea94bb",
"fontFamily": "Bangers",
"textAlign": "right"
},
"text": data[i][filter],
"x": ( 220 * horizontal ),
"y": ( 220 * vertical )
})

Regardless of what color I substitute in the backgroundColor property, I cannot get the stickies to generate as that color. They always get created yellow. I have run this same method with the “shape” widget and I get the correct specified background color. 

It there some nuanced approach to coloring stickers that I am just overlooking? I have been through the API documentation at least two dozen times. 

icon

Best answer by Anthony Roux 18 May 2021, 12:26

Hi @uxmccauley,

 

It can be a bit confusing but the background color parameter for stickers is different than the one for shapes. You can find it documented here.

 

In your case you need to replace backgroundColor by stickerBackgroundColor.

 

This should solve the issue.

Anthony

View original

5 replies

Userlevel 2
Badge +6

Hi @uxmccauley,

 

It can be a bit confusing but the background color parameter for stickers is different than the one for shapes. You can find it documented here.

 

In your case you need to replace backgroundColor by stickerBackgroundColor.

 

This should solve the issue.

Anthony

Badge +1

Oh neato! Thanks so much. I will try that today. 

Badge +1

I tried that and I get this error. 

 

Badge +1

Guess what, I realized that I am an idiot. I moved that prop into the style object and it works great now! Let’s just find a way to dynamically add tags and life will be amazing. 

Userlevel 2
Badge +6

FYI: when using Styling, some elements are actually enums (this is the case for “textAlign”). You can take a look at this post to see how to use the Miro SDK enums. 

 

Not sure what you are trying to do with tags but you can easily tag stickers using something like:

 

let allStickers = await miro.board.widgets.get({type: 'sticker'})

miro.board.tags.create({title: 'Red tag', color: '#F24726', widgetIds: allStickers})

 

Reply