Skip to main content
Solved

Adding a shadow to a frame via a plugin

  • February 12, 2024
  • 3 replies
  • 356 views

Jonah_Goldsaito

Based on the plugin Effect API page, I would assume this is the right format for assigning an drop shadow to a node:

newFrame.effects = [{
type: “DROP_SHADOW”,
color: {r: 0, g: 0, b: 0, a: 1},
offset: { x: 0, y: 4},
radius: 4,
}];

Unfortunately it fails silently. Anyone know how to do this properly?

Also, for any Figma team members out there, would be great to:

  • Get an error that highlights the malformed property causing this to fail
  • Have an example on the API page

Best answer by tank666

Add all required properties (including blendMode, visible).

figma.com

You should see errors in the console.

View original
This topic has been closed for comments

3 replies

tank666
  • 4868 replies
  • Answer
  • February 12, 2024

Add all required properties (including blendMode, visible).

figma.com

You should see errors in the console.


Jonah_Goldsaito

Hey @tank666, thanks!

I didn’t notice the ? syntax on the variable names. That fixed it! 🙌

Notes to the Figma team:

  • Why are properties like visible and blendMode not given very obvious defaults of true and NORMAL respectively? The blendMode description even says, "The typical default value is “NORMAL”.
  • Showing an error for what’s missing would be amazing!
  • Stating required in plain text in the description would be way harder to miss.

Jonah_Goldsaito

Oops. Was missing the error amongst other noise.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings