Using components from a design library file within a plugin

I thought I did. Looking at the screenshot below, wouldn’t it be “Project Status”?
Screen Shot 2023-07-03 at 1.18.28 PM

Could you share a link to an example file?

Because of work restrictions I am limited on what I can share, but here is the blank component that I am placing:

‘Cover’ component set to the ‘In Progress’ ‘Project Status’

Then this is the variants I am able to select from:
Screen Shot 2023-07-03 at 2.23.59 PM
Screen Shot 2023-07-03 at 2.24.10 PM

Here is the main bit of code that places the component the first time you run it:

figma.ui.resize(440, 450);

figma.ui.onmessage = async (pluginMessage) => {
    // Define the key of the component set
    const coverComponentSetKey = '###';

    // console.log('Importing component set...');
    const coverComponentSet = await figma.importComponentSetByKeyAsync(coverComponentSetKey);
    // console.log('Component set imported:',;

   console.log('Definitions', coverComponentSet.componentPropertyDefinitions);

    const selectedVariantName = variantMap[pluginMessage.selectedValue];
    console.log('Dropdown Status:', selectedVariantName);

    const selectedVariant = coverComponentSet.findOne (
                (node) => node.type === 'COMPONENT' && === selectedVariantName

    console.log('Status to be set:',;

    if (selectedVariant) {
        const instance = selectedVariant.createInstance();

        const coverComponent = instance

        if (coverComponent) {
            figma.currentPage.selection = [coverComponent];

--- minus a chunk ---




In the code I am using to update the component I check to see if the ‘Cover’ instance is there and then retrieve data from the Text Nodes to re-populate the UI where the user puts in the various points of info. The only thing not working is changing the current instance of the ‘Cover’.

This is what the ‘Done’ variant looks like:

Here are the Figma layers:
Screen Shot 2023-07-03 at 2.37.12 PM

I am guessing I am on my own now, I am sure that this data I have provided isn’t enough. lol

Using this code I am returning the current variant successfully, but it is not finding any of the other variantOptions:

const variantKey = Object.keys(variantMap).find((key) => variantMap[key]);