跳转到内容

Styles

管理本地颜色、文字、效果和网格样式。

Type reference
// Styles are named, reusable design properties that can be applied to nodes. Four types:
// paint: a named color (applied to fills/strokes), text: typography settings, effect: shadows/blurs, grid: layout grids.
// All ID params accept both IDs and display names (case-insensitive). Use whichever you have.
// ---
// leadingTrim: "CAP_HEIGHT" trims line-height to cap height (tighter text boxes), "NONE" is default.
// fontStyle: font variant name like "Bold", "Italic", "Bold Italic". Use fonts.list to find available styles.
//
// Effect object shape (for effect styles):
// { type: "DROP_SHADOW"|"INNER_SHADOW"|"LAYER_BLUR"|"BACKGROUND_BLUR",
// color?: Color, offset?: {x, y}, radius: number, spread?: number,
// visible?: boolean, blendMode?: string }
// DROP_SHADOW/INNER_SHADOW require color, offset, radius. LAYER_BLUR/BACKGROUND_BLUR require radius only.
// Example: { type: "DROP_SHADOW", color: "#00000040", offset: {x:0,y:4}, radius: 8 }
//
// LayoutGrid object shape (for grid styles):
// Rows/Columns: { pattern: "ROWS"|"COLUMNS", alignment: "MIN"|"MAX"|"STRETCH"|"CENTER",
// gutterSize: number, count: number, sectionSize?: number, offset?: number, visible?: boolean, color?: Color }
// Grid: { pattern: "GRID", sectionSize: number, visible?: boolean, color?: Color }
// Example: { pattern: "COLUMNS", alignment: "STRETCH", gutterSize: 20, count: 12, offset: 40 }

5 methods available.

List local styles with optional type filter

ParameterTypeRequiredDescription
type"paint" | "text" | "effect" | "grid"Filter by style type
fieldsstring[]Property whitelist. Identity fields (id, name, type) always included. Omit for stubs on list, full on get. Pass ["*"] for all.
offsetnumberSkip N items for pagination (default 0) (default: 0)
limitnumberMax items per page (default 100) (default: 100)

Response

FieldTypeDescription
totalCountnumberTotal matching items
returnednumberItems in this page
offsetnumber
limitnumber
itemsobject[]
idstring
namestring
typestring

Get full style detail by ID

ParameterTypeRequiredDescription
idstringStyle ID or name
fieldsstring[]Property whitelist. Identity fields (id, name, type) always included. Omit for stubs on list, full on get. Pass ["*"] for all.

Response

FieldTypeDescription
idstring
namestring
typestringPAINT | TEXT | EFFECT | GRID
paintsarrayPaint fills (PAINT styles)
fontFamilystringFont family (TEXT styles)
fontSizenumberFont size (TEXT styles)
effectsarrayEffects array (EFFECT styles)
layoutGridsarrayLayout grids (GRID styles)

Create local styles

No parameters.

Discriminated by type. Available types:

Paint/color style

ParameterTypeRequiredDescription
namestringStyle name
colorstringColor value. Optional when colorVariableName is provided.
colorVariableNamestringBind to a COLOR variable by name (style tracks the variable). Can be used alone — color is resolved from the variable.
descriptionstringStyle description

Text style

ParameterTypeRequiredDescription
namestringStyle name
fontFamilystringFont family
fontStylestringFont style (default: Regular)
fontSizenumberFont size
lineHeightanynumber | {value, unit: "PIXELS"|"PERCENT"|"AUTO"}
letterSpacinganynumber | {value, unit: "PIXELS"|"PERCENT"}
textCase"ORIGINAL" | "UPPER" | "LOWER" | "TITLE" | "SMALL_CAPS" | "SMALL_CAPS_FORCED"
textDecoration"NONE" | "UNDERLINE" | "STRIKETHROUGH"
paragraphIndentnumberParagraph indent (px)
paragraphSpacingnumberParagraph spacing (px)
leadingTrim"CAP_HEIGHT" | "NONE"Leading trim mode
descriptionstringStyle description

Effect style

ParameterTypeRequiredDescription
namestringStyle name
effectsarrayArray of Effect objects
descriptionstringStyle description

Grid/layout grid style

ParameterTypeRequiredDescription
namestringStyle name
layoutGridsarrayArray of LayoutGrid objects
descriptionstringStyle description

Response

FieldTypeDescription
resultsobject[]One entry per input item
idstring

Update styles by ID or name

ParameterTypeRequiredDescription
type"paint" | "text" | "effect" | "grid"Style type hint for strict validation (optional, auto-detected)
itemsobject[]Array of {id, ...fields} to update
idstringStyle ID or name
namestringRename the style
descriptionstringStyle description
colorstringNew color (paint styles)
colorVariableNamestringBind to a COLOR variable by name (paint styles)
fontFamilystring
fontStylestring
fontSizenumber
lineHeightanynumber | {value, unit: "PIXELS"|"PERCENT"|"AUTO"}
letterSpacinganynumber | {value, unit: "PIXELS"|"PERCENT"}
textCase"ORIGINAL" | "UPPER" | "LOWER" | "TITLE" | "SMALL_CAPS" | "SMALL_CAPS_FORCED"
textDecoration"NONE" | "UNDERLINE" | "STRIKETHROUGH"
paragraphIndentnumberParagraph indent (px)
paragraphSpacingnumberParagraph spacing (px)
leadingTrim"CAP_HEIGHT" | "NONE"
effectsarrayArray of Effect objects
layoutGridsarrayArray of LayoutGrid objects (grid styles)

Response

FieldTypeDescription
resultsany[]Array of "ok" or {error} per item

Delete styles

ParameterTypeRequiredDescription
idstringStyle ID or name
itemsobject[]Batch: [{id}, ...]
idstringStyle ID or name

Response

FieldTypeDescription
resultsstring[]Array of "ok" per item