Sets the active state of the selected component, so you can preview it on the canvas from your panel.
| Name | Type | Description |
|---|---|---|
stateKey | string | null | Key of the state to activate. Must match a key returned by getStateDefinitions(). Pass null to return to the default state. |
Note: For a state without a pseudoClass, setState() only changes what a Wix user sees while editing in the editor. It has no effect on the live site. If you need a toggle that persists for site visitors, store it in a data field with setData() instead.
Promise<void>
Last updated: 8 September 2026