useVariableModes
useVariableModes() provides headless state and actions for Figma's Apply variable mode control: the collections a mode can be set for on the selection, or on the current page when nothing is selected, and the mode each one shows.
Usage
ts
import { useVariableModes } from '@open-pencil/vue'
const { choices, applied, setMode } = useVariableModes()choiceslists the collections with more than one mode that the selected layers use, through their own bindings or variables those alias; for a page, every such collection. Each has itsmodes, itsvalue(the mode set on every target,MIXEDwhen they differ, ornullfor Auto), and theinheritedmode the targets show without one of their own.appliedis the part ofchoiceswith a mode set on at least one target, which a panel shows as rows.setMode(collectionId, modeId)sets the mode on every target in one undo step;nullclears it, so the targets inherit their parent's mode again.
variableModeChoices(editor, nodes) and setVariableMode(editor, nodes, collectionId, modeId) do the same for any layers, outside a component.