Skip to main content
D_S
Jul 6, 2021 7:34 PM UTC
Solved

Passing Code.JS or Code.TS values/variables to UI.HTML

Hello! I’m currently working on a plugin and I’m trying to pass the Font Size value to display within my Plugin UI. I’m retrieving the value via const selection = figma.currentPage.selection["0"].fontSize; but I can’t seem to get it to display within my plugin UI. I’ve tried document.getElementById('font_field').innerText = (figma.currentPage.selection["0"].fontSize); but no luck.

My main goal is to actually just pass the value to a tensor flow script that’s working within my html doc but to also display it within the UI.

How do I communicate between the two files? : )

Thank you!!

This topic has been closed for replies.
tank666
tank666Solution
Jul 6, 2021 8:44 PM UTC

You must send the message using postMessage.

figma.com
UX/UI designer. Figma expert. Creator and developer of plugins and widgets for Figma and FigJam. Check out my resources in Figma Community: figma.com/@tank

3 replies

tank666
tank666Solution
Jul 6, 2021 8:44 PM UTC

You must send the message using postMessage.

figma.com
UX/UI designer. Figma expert. Creator and developer of plugins and widgets for Figma and FigJam. Check out my resources in Figma Community: figma.com/@tank
D_S
D_SAuthor
Jul 6, 2021 11:02 PM UTC

Worked like a charm, thank you!

Leonardo_Ratzlaff1
Feb 27, 2024 1:28 AM UTC

I’m using postMessage

figma.ui.postMessage({ type: 'results', updatedComponents}, '*');

but I get the following error:
Uncaught DOMException: Blocked a frame with origin "null" from accessing a cross-origin frame.