Skip to main content
Erik6
May 13, 2022
Question

How to change the property of different components in prototyping.?

  • May 13, 2022
  • 21 replies
  • 15978 views

Hey 🙂

Currently I am working on a big project, that involves a lot of different state of different components.

Is it possible to change the property of an element/component through clicking on another object?
Given my screenshot below it should be, no?

But linking this rectangle with the below component doesn’t work at all.
I would love to be able to switch the state of the linked object when I click this (example) rectangle in prototyping.
The linked object has different properties available, but I can’t select them tho.

Could you please explain my what I am doing wrong?

Thank you 🙂
Cheers

This topic has been closed for replies.

21 replies

Erik6
Erik6Author
May 13, 2022

Heres another example of what I want to do:

So basically should the click on a child elemente change the state of the parent element and vice versa.

Is this possible too?

Shash_Patel
August 1, 2022

I’ve only found really laborious hacks to do such things. I really think there should be a feature around this.

One possible way for the Figma team to explore is in the IX menu details for a ‘click’ action, where ‘change state’ is not assumed to be change of the element that is selected for this interaction, but a ‘remote’ element somewhere else on that page. This way a click of one object can be tied to a state change of another object.

This would massively enable new IX patterns without ‘Invision’ style hacks all over my prototype to mock separate screen states that have the differences illustrated. Currently I have use the ‘navigate to’ with a separate screen setup with that desired state. While this workaround hack somewhat works, it means many many copies of screens to manage the various states, and it quickly blows up if you have multiple states to manage in your flows.

It is also tied into a limitation that only 1x of each IX can be used. A ‘click’ should be possible to trigger multiple things, imho.

Bill_Stewart_S
New Participant
November 25, 2022

Agreed. This is a painful limitation.

Chris_Passmore
December 12, 2022

For all the cool ‘tricks’ that Figma offers, being able to affect the parent state/layer property from a child would truly change the game. It would enable accordion/windowshade components (click on header to hide/show content below).

May 10, 2023

This is such a huge problem for me right now. I have had to make many many duplicates of pages to show how the dependencies of a button being clicked play out. I also agree with having more than one event being mappable to an action. This would reduce my workload by a solid 40% if I could just set some really basic dependencies.

June 1, 2023

Following the discussion here, This feature is a must-have.
being able to change 1 component’s properties from a different component is a basic thing, we need to be able to change the global state or something like that to achieve this.

Luis_Alves1
July 3, 2023
  • 1 for this feature. Even now with the new additions from the latest keynote this is still not possible. variables don’t affect component properties.
Andreea
July 13, 2023

I hear you, I ran into this issue too, it’s definitely a pain point. The only way to get around this at the moment is to use a global variable.

Any element on the canvas can change the value of a global variable, and this variable in turn can be used to control the state of any other element (no parent-child connection is necessary between the elements). I’m not sure if I can explain it very well, but here’s a good demo from Figma on how you can achieve this: Figma tutorial: Prototype with variables - YouTube .

Consider how the global “hasCart” variable is used in the demo to connect the “Add to cart” and the “Basket” buttons to each other, even though they are completely unrelated components. In the same way, you could set an interaction on your dropdown component (_Struktur-Mehr An…) to set a global variable, and link the value of that variable to the visibility of the variants in your form component (Kundeneingabe-Felder-Layout-Variaten).

Hope this helps you! 🙂

IanCox
New Participant
August 6, 2023

This is 100% possible. As Andreea said above, you can use a boolean global variable to toggle visibility of other elements. BUT you can also use a string global variable to set the component properties of another variable.

In short, use a global variable with a boolean value to manage visibility and use a global variable with a string value to set component properties.

Toggling visibility:

  1. Create a new boolean variable named notificationVisible and set it’s default value to false
  2. For a button component, create an on-click interaction that sets the notificationVisible variable true.
  3. Set the visibility of the notification component to mirror the value of the notificationVisible boolean variable

Using the interaction of one component to set the component properties of another:

  1. Create a button to act as our controller.
  2. Create a component with 2 variants, in this example the component we want to control is called status and has a property called color and two variants, red and green.
  3. Create a global string variable called status and set it to our default component property value (“green”)
  4. On button click, set the status variable to a string value of “red”
  5. In the instance of the component value where you can select properties to switch to different variants, set that property to be driven be the string value stored in the status variable.

So long as the string stored in the variable is the same name (case sensitive) as a real value from the component property, things will work and you will be able to use the interactions of one component to drive the state of another component.

CleanShot 2023-08-06 at 01.13.58

Joshua_Feig
New Member
August 31, 2023

This was really helpful. Thanks!