New in Sketch 2026.2
Important Changes to Document Layout and Styling Updates
Sketch 2026.2 introduced a lot of performance improvements that affected how certain changes made to Stacks, Concentric Corners, Shared Styles, and Swatches via SketchAPI are reflected in the document.
Previously, whenever a script made any changes to, say, a Stack by modifying one of its properties, Sketch would immediately perform a synchronous document layout update to reflect that change. If a script happened to modify multiple properties in a row, a full layout would be performed each time, which degraded the overall performance of the script.
Starting with version 2026.2, Sketch will now try to batch multiple layout and styling updates together and defer them until it makes the most sense to actually perform them. If your scripts not only create or modify layout and styling properties, but also read them back (e.g. to determine a full Stack height after adjusting its paddings and adding children layers), you might need to add explicit calls to Document.processPendingChanges() to make sure you get back the most up-to-date data:
-
For Stacks, call
Document.processPendingChanges()after you’ve finished making changes to a particular StackLayout:frame.stackLayout.wraps = true frame.stackLayout.padding = 42 document.processPendingChanges() -
For Concentric Corners, call
Document.processPendingChanges()after making changes that might affect concentricity:const parent = new Group.Frame({ style: { corners: { radii: 20 }, }, // ... }) const layer = new ShapePath({ style: { corners: { concentric: true }, }, parent: parent, // ... }) // 1) At this point the layer doesn't have a calculated corner radius just yet console.log(layer.style.corners.radii) // Outputs: [0] // 2) Calling `processPendingChanges()` on the parent document will trigger // the concentric corner calculations and assign an actual radius value to the layer document.processPendingChanges() console.log(layer.style.corners.radii) // Outputs: [10] -
For Shared Styles, call
Document.processPendingChanges()after modifying a SharedStyle to immediately propagate those changes to all instances:// 1) At this point the layer is fully synchronized with its shared style const layer = new Shape({ sharedStyle: sharedStyle, // ... }) // 2) Now if we update the shared style, the layer will become out of sync: sharedStyle.style.opacity = 0.5 console.log(layer.style.isOutOfSyncWithSharedStyle(sharedStyle)) // Outputs: true // 3) Calling `processPendingChanges()` on the parent document will synchronize // this layer's style with the shared one: document.processPendingChanges() console.log(layer.style.isOutOfSyncWithSharedStyle(sharedStyle)) // Outputs: false -
For Swatches, call
Document.processPendingChanges()after modifying a Swatch color to immediately propagate it to all instances:const swatch = document.swatches[0] swatch.color = '#000000ff' // 1) At this point the layer's fill color is fully synchronized with its Swatch const layer = new ShapePath({ parent: document.selectedPage, style: { fills: [{ swatch: swatch }], }, }) // 2) Now if we update the Swatch value, the layer's fill will become out of sync: swatch.color = '#c0ffeeff' console.log(layer.style.fills[0].color) // Outputs: #000000ff // 3) Calling `processPendingChanges()` on the parent document will synchronize // this layer's fill color with the Swatch: document.processPendingChanges() console.log(layer.style.fills[0].color) // Outputs: #c0ffeeff
Libraries
Added support for Document Libraries
Document Libraries are now fully supported in SketchAPI:
- Discover available Document Libraries via
Library.getLibraries(document)ordocument.getLibraries(). - Associate a Library with a Document via
document.addLibrary(library). - Remove an association via
document.removeLibrary(library).
Updated Library.getLibraries() to filter out unavailable libraries by default
Library.getLibraries() will now only return libraries that are actually available to use in the given context:
- When called without arguments, it returns only the libraries that are enabled under Settings > Libraries.
-
When called with a single
documentargument, it returns the libraries that are enabled under either Settings > Libraries or File > Document Settings > Libraries for the given document:const document = ... const libraries = Library.getLibraries(document) // or const libraries = document.getLibraries() -
When called with
options.includeUnavailable: true, it returns the full, unfiltered list of libraries (the original behavior prior to Sketch 2026.2):Library.getLibraries({ includeUnavailable: true }) Library.getLibraries(document, { includeUnavailable: true })
Frame Templates
Frame Templates are now fully supported in SketchAPI.
-
Use the
isTemplateproperty to mark a Frame/Graphic as a Template:const myFrame = new sketch.Group.Frame(...) myFrame.isTemplate = true -
Use
Document.frameTemplates/graphicTemplatesto access document-local Templates:const template = document.frameTemplates.find( (t) => t.name === 'Mobile Template', ) -
Use
Library.getImportableFrameTemplateReferencesForDocument()/getImportableGraphicTemplateReferencesForDocument()to access library Templates:const template = library .getImportableFrameTemplateReferencesForDocument(document) .find((t) => t.name === 'Mobile Template') -
Use
import()to import a Frame Template into a document as a new Frame:const newFrame = template.import() document.selectedPage.layers.push(newFrame)
Frames
- Added new methods to convert between various container types: Groups, Frames, and Graphics:
group.convertToFrame() frame.convertToGroup() group.convertToGraphic() - Deprecated the
groupBehaviorproperty in favor of:isFrameandisGraphicFramefor determining the type of a container- New
convertTo*()methods for switching between container types
- Fixed a bug that prevented new Frames from being created with an explicit background color
- Fixed an issue where SketchAPI would ignore the
background.enabledoption when creating a new Frame - Fixed a
TypeErrorwhen attempting to assign a background color value for a Frame that has a non-emptystyle.fillsarray where all fills are disabled
Shared Styles
- Deprecated
sharedStyleIdproperty in favor ofsharedStyle - Made
sharedStylesetter automatically apply the newly assigned shared style to the layer
Overrides
- Added the
reset()method to reset the given Override to its default value - Added the
textOverrideandimageOverrideproperties to help identify text and image Overrides - Fixed a TypeError when accessing
valueanddefaultValueproperties on Overrides when the underlying Sketch model doesn’t have a value
Text
We’ve removed the double/thick/pattern underlying and strike-through options to match text styling options currently available in Sketch.
Other Changes and Bugfixes
- Fixed a crash when trying to re-insert a layer into its current parent
- Fixed a bug where SketchAPI would implicitly convert canvas-level Graphics to Frames returned from
Page.layers,Page.canvasLevelFrames,orsketch.find()