Complete the code to activate the eyedropper tool in Figma.
figma.currentPage.selection[0].fills = figma.[1]();
The eyedropper() function activates the eyedropper tool to pick colors in Figma.
Complete the code to store the color picked by the eyedropper tool.
const pickedColor = await figma.[1]();The eyedropper() function returns a promise that resolves to the color picked.
Fix the error in the code to correctly apply the picked color to a rectangle's fill.
rectangle.fills = [{ type: 'SOLID', color: [1] }];The eyedropper returns a color object compatible with the fill color property, so use pickedColor directly.
Fill both blanks to create a function that picks a color and applies it to a selected shape.
async function applyColor() {
const color = await figma.[1]();
figma.currentPage.selection[0].fills = [{ type: 'SOLID', color: [2] }];
}The function eyedropper() picks the color, which is stored in color and then applied.
Fill all three blanks to pick a color, check if a shape is selected, and apply the color.
async function pickAndApply() {
if (figma.currentPage.selection.length === [1]) {
const [2] = await figma.[3]();
figma.currentPage.selection[0].fills = [{ type: 'SOLID', color: pickedColor }];
}
}You check if exactly one shape is selected (1), then pick the color with eyedropper() and store it in pickedColor.