Skip to main content

getVariablesInLibraryCollectionAsync

Returns a descriptor of all Variables that exist in a given LibraryVariableCollection. Rejects if the given variable collection does not exist, or if the current user does not have access to that variable collection's library, or if the request fails.

Signature

getVariablesInLibraryCollectionAsync(libraryCollectionKey: string): Promise<LibraryVariable[]>

Parameters

libraryCollectionKey

the key of the library variable collection that contains the returned library variables.

Example usage

Example usage of getVariablesInLibraryCollectionAsync
// Query all published collections from libraries enabled for this file
const libraryCollections =
await figma.teamLibrary.getAvailableLibraryVariableCollectionsAsync()
// Select a library variable collection to import into this file
const variablesInFirstLibrary =
await figma.teamLibrary.getVariablesInLibraryCollectionAsync(libraryCollections[0].key)
// Import the first number variable we find in that collection
const variableToImport =
variablesInFirstLibrary.find((libVar) => libVar.resolvedType === 'FLOAT')
const importedVariable =
await figma.variables.importVariableByKeyAsync(variableToImport.key)