code-connect icon indicating copy to clipboard operation
code-connect copied to clipboard

Variant restriction from nestedProps

Open alisonjoseph opened this issue 1 year ago • 3 comments

It would be helpful to be able to create a variant restriction from a nested prop. Is this currently possible?

alisonjoseph avatar Jul 08 '24 17:07 alisonjoseph

this would be also very helpful on Figma client 😅

0xa3k5 avatar Jul 12 '24 14:07 0xa3k5

+1 Agree this would be helpful 🙏 I'm currently trying to create a variant based on a nested prop. This is my use case

figma.connect(Input, figmaUrl, {
  props: {
      input: figma.nestedProps('Text Field', {
            leftIcon: figma.boolean('Show left icon', {
              true: figma.instance('Left icon').getProps(),
              false: undefined,
            }),
     }
  },
  variant: { 'Show left icon': true }, // doesn't work because this only works for parent properties
  example: ({ input }) => (
    <Input>
      <Input.Icon name={input.leftIcon.name} />
    </Input>
  ),
})

Alternatively, if we could conditionally render based on the props and do away with the variant restrictions, it would solve the issue as well. Thank you Figma team!

chishancircle avatar Jul 17 '25 15:07 chishancircle

We are experiencing the same issue, would love to be able to render a completely different react component based on the value of a nested property

tijmenvangurp avatar Aug 15 '25 14:08 tijmenvangurp