JavaScript properties
Set properties when values come from application state. Attribute-backed properties reflect the same configuration exposed in HTML.
const drawing = document.querySelector("web-draw");theme
Set the theme to "auto", "light", or "dark".
drawing.theme = "dark";viewModeEnabled
Set a boolean to control read-only viewing.
drawing.viewModeEnabled = true;zenModeEnabled
Set a boolean to hide or restore the main editor controls.
drawing.zenModeEnabled = true;gridModeEnabled
Set a boolean to show or hide the grid.
drawing.gridModeEnabled = true;library
Assign the same JSON string accepted by the library attribute. Assign "[]" to clear it or null to fall back to storageKey.
drawing.library = JSON.stringify([
{ id: "box", name: "Box", elements: [savedRectangle] },
]);libraryEnabled
Set "on" to show the library button or "off" to hide it. The default is "on".
drawing.libraryEnabled = "on";storageKey
Assign a localStorage key. Use an empty string when the host application handles persistence.
drawing.storageKey = "account-42-library";initialData
Set the initial scene after creating the component. It accepts elements, files, and a subset of application state.
drawing.initialData = {
elements,
files,
appState: {
theme: "light",
viewBackgroundColor: "#fff9db",
zoom: 1,
scrollX: 0,
scrollY: 0,
currentItemRoundness: "round",
},
};elements
Assign an array to replace the rendered scene elements directly. Prefer updateScene() when files or application state must change at the same time.
drawing.elements = nextElements;