Skip to main content

sdk.objectapi.setlockedstate

Home > @kittl/sdk > ObjectAPI > setLockedState

ObjectAPI.setLockedState() method

Locks and unlocks an object in the design, preventing it from being selected, moved, or modified.

When an object is locked, it becomes non-interactive in the canvas: - Cannot be selected by clicking or selection tools - Cannot be moved or transformed - Selection controls and handles are hidden - Cannot be edited or modified - Remains visible but is protected from accidental changes

This is useful for protecting important design elements like backgrounds, logos, or finalized content while continuing to work on other parts of the design.

Signature:

setLockedState(params: SetLockedParams, opts?: DesignApiOptions): WithLocked;

Parameters

Parameter

Type

Description

params

SetLockedParams

Configuration parameters for locking the object

opts

DesignApiOptions

(Optional) Additional options for the design API operation

Returns:

WithLocked

Result object containing the updated object

Exceptions

When the specified object ID is not found in the design state

When the object ID is invalid or empty

Example

const objectApi = new ObjectAPI(projectManager, store);

// Lock a background image to prevent accidental modification
const result = await objectApi.setLockedState({
id: 'background-image-123',
locked: true
});
// result: { id: 'background-image-123', locked: true }