New in Sketch 2026.4
Variants
const component = new sketch.Group.VariantSet({
name: 'My Set',
parent: document.selectedPage,
// (Optional) Configure variant properties right away
variantProperties: [
{ name: 'Size', values: ['S', 'M', 'L'] },
{ name: 'Color', values: ['BW', 'Blue', 'Golden'] },
],
// (Optional) Bring existing Symbol Masters as variants in this set
layers: [master1, master2],
})
component.isVariantSet
// => true
master1.isVariant
// => true
master1.getParentVariantSet()
// => Group.VariantSet(name: 'My Set', ...)
To find an existing VariantSet in the given document:
const variantSets = document.getVariantSets()
const aVariantSet = document.getVariantSetWithID('...')
Access and assign values for variant properties on individual SymbolMasters:
master1.variantConfiguration
// => {}
master1.variantConfiguration = {
Size: 'S',
Color: 'Golden',
}
// => { "Size": "S", "Color": "Golden" }
master1.variantConfiguration = Object.assign(master1.variantConfiguration, {
Color: 'BW',
})
// => { "Size": "S", "Color": "BW" }
And if you want to know which variant from the set is most suitable for the given configuration:
// could be a full spec
let configuration = {
Size: 'L',
Color: 'BW',
}
// or just a partial one
configuration = {
Color: 'BW',
}
const variant = component.getBestVariantMasterForConfiguration(configuration)
Variant properties themselves are a mutable collection (just like Group.layers):
// Reading
component.variantProperties.forEach((prop) => {
console.log(`${prop.name} => ${prop.values}`)
})
// Renaming
component.variantProperties[1].name = 'Theme'
// Adding new ones
component.variantProperties.push({
name: 'Shape',
values: ['Oval', 'Circle', 'Triangle'],
})
// Updating a set of possible values
// NOTE: duplicate values will be ignored
component.variantProperties[1].values = ['Light', 'Dark']
// Renaming an individual value of a variant property:
component.variantProperties[0].renameValue('S', 'Small')
// Deleting a property
component.variantProperties.pop() // or use splice()
To dissolve a VariantSet into independent Symbol Sources:
component.ungroup()
Import VariantSets from libraries:
const variantSetRefs =
library.getImportableVariantSetReferencesForDocument(document)
const importedVariantSet = variantSetRefs[0].import()
const master = importedVariantSet.getBestVariantMasterForConfiguration({
Type: 'List',
Mode: 'Compact',
Highlight: 'Triple',
})
Sections
const section = new sketch.Group.Section({
name: 'Onboarding',
layers: [frame1, frame2],
})
section.isSection
// => true
frame1.getParentSection()
// => Group(name: 'Onboarding', ...)
A new Section has no parent, even when it wraps layers that are already in a document. Set its parent to a page or another Section to place it.
You can also convert a group to a section with group.convertToSection(). The method returns false if the conversion is not allowed.
Layer Transform Properties
Use layer.rotation, layer.flippedHorizontally, and layer.flippedVertically as shortcuts for the corresponding layer.transform properties.
Faster Override Updates
You can dramatically reduce the computational overhead of updating multiple Override values in a row by using the new SymbolInstance.updateOverrides() API:
// Before (slow)
instance.overrides.forEach((o) => {
if (o.property === 'stringValue') {
o.value = 'a text override'
}
})
// After (fast)
instance.updateOverrides((overrides) => {
// ⚠️ You must use the provided `overrides` variable
overrides.forEach((o) => {
if (o.property === 'stringValue') {
o.value = 'a bulk-updated text override'
}
})
})
Scaling Layers
Use the new Layer.scale() method to scale a layer and its style properties the same way as the Scale tool. Pass a ScaleOrigin to choose the point of the layer that stays in place:
layer.scale(1.5) // 150%, keeping the top-left corner in place
layer.scale(0.5, { origin: sketch.ScaleOrigin.Center })
Bugfixes
- Fixed an issue where a Frame created with an empty or disabled
style.fillswould still have a default background - Fixed an issue where a shared text style created from a plain object would lose its text attributes
- Fixed an issue where all text attributes of a shared text style would be reported as
undefined
sketchtool
We’ve renamed some sketchtool commands and options:
| Old name | New name |
|---|---|
export artboards |
export frames |
export components |
export assets |
--include-symbols |
--include-components |
The previous names remain as aliases, so your scripts continue to work as-is, and dedicated help <command> output lists the aliases. Exported artifact names and manifest schemas remain unchanged as well.