How to replace one instance with multiple other instances?

I need to know some API methods that can replace one instance with other instances, I only found the swapComponent method, but it seems to only replace a single component with another single component, I want to be able to replace one component with multiple components.

I’m developing a plugin using the Figma API, the goal is to parse the user input component tree JSON to draw mockups in Figma. I have a Accordion component already in lib to ensure a uniform style of reuse and expand the content when it is in the Open state, it is pre-defined as a Slots instance like this. If the user wants to replace the Slots with a Button instance, I can use the swapComponent method. But if the user wants to replace the Slot with something more complex, like a Frame with multiple child elements, I can’t find a way to do that.

In the page design, like Tab, Accordion, Modal, these types of complex components may have internal subcomponents nested with other more complex components, and I need to deal with this kind of problem urgently.

Better category for this post would be #plugin-widget-api:plugin-questions

Answer: There is no such feature in Figma, so it’s not possible to implement such functionality with a plugin. The only way is to create a component that has multiple instances inside and swap to it. There is no way to dynamically change the number of children in an instance — that’s how components work in Figma.

Thank you for your answer. But I do very much hope that Figma will implement such a feature, and I hope you will consider doing some work on this in the future. As I described in my question, I am working on a plugin that will have a large user base. This plugin allows the user to input a JSON data describing the structure of the components in the page, and I parse this data and draw each component in the canvas by CreateInstance method, now I have no way to replace the components in the nested components like Accordion.