/
figma.d.ts
835 lines (781 loc) · 31.6 KB
/
figma.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
interface Node {
// A string uniquely identifying this node within the document.
id: string;
// The name given to the node by the user in the tool.
name: string;
// Whether or not the node is visible on the canvas.
// default: true
visible?: boolean;
// fixed?
isFixed?: boolean;
// The type of the node, refer to table below for details.
type: string;
// Data written by plugins that is visible only to the plugin that wrote it. Requires the `pluginData` to include the ID of the plugin.
pluginData: any;
// Data written by plugins that is visible to all plugins. Requires the `pluginData` parameter to include the string "shared".
sharedPluginData: any;
}
interface DocumentNode extends Node {
type: "DOCUMENT";
// An array of canvases attached to the document
children: CanvasNode[];
}
interface CanvasNode extends Node {
type: "CANVAS";
// An array of top level layers on the canvas
children: SceneNode[];
// Background color of the canvas.
backgroundColor: Color;
// [DEPRECATED] Node ID that corresponds to the start frame for prototypes. This is deprecated with the introduction of multiple flows. Please use the flowStartingPoints field.
prototypeStartNodeID: string;
// A array of flow starting points sorted by its position in the prototype settings panel.
// default: []
flowStartingPoints?: FlowStartingPoint[];
// An array of export settings representing images to export from the canvas
// default: []
exportSettings?: ExportSetting[];
}
interface FrameNode extends Node {
type: "FRAME";
// An array of nodes that are direct children of this node
children: SceneNode[];
// If true, layer is locked and cannot be edited
// default: false
locked?: boolean;
// [DEPRECATED] Background of the node. This is deprecated, as backgrounds for frames are now in the fills field.
background: Paint[];
// [DEPRECATED] Background color of the node. This is deprecated, as frames now support more than a solid color as a background. Please use the fills field instead.
backgroundColor: Color;
// An array of fill paints applied to the node
// default: []
fills?: Paint[];
// An array of stroke paints applied to the node
// default: []
strokes?: Paint[];
// The weight of strokes on the node
strokeWeight: number;
// Position of stroke relative to vector outline, as a string enum
strokeAlign: string;
// Radius of each corner of the frame if a single radius is set for all corners
cornerRadius: number;
// Array of length 4 of the radius of each corner of the frame, starting in the top left and proceeding clockwise
// default: same as cornerRadius
rectangleCornerRadii?: number[];
// An array of export settings representing images to export from the node
// default: []
exportSettings?: ExportSetting[];
// How this node blends with nodes behind it in the scene (see blend mode section for more details)
blendMode: BlendMode;
// Keep height and width constrained to same ratio
// default: false
preserveRatio?: boolean;
// Horizontal and vertical layout constraints for node
constraints: LayoutConstraint;
// Determines if the layer should stretch along the parent’s counter axis. This property is only provided for direct children of auto-layout frames.
layoutAlign: string;
// Node ID of node to transition to in prototyping
// default: null
transitionNodeID?: string;
// The duration of the prototyping transition on this node (in milliseconds)
// default: null
transitionDuration?: number;
// The easing curve used in the prototyping transition on this node
// default: null
transitionEasing?: EasingType;
// Opacity of the node
// default: 1
opacity?: number;
// Bounding box of the node in absolute space coordinates
absoluteBoundingBox: Rectangle;
// Width and height of element. This is different from the width and height of the bounding box in that the absolute bounding box represents the element after scaling and rotation. Only present if geometry=paths is passed
size: Vector;
// The top two rows of a matrix that represents the 2D transform of this node relative to its parent. The bottom row of the matrix is implicitly always (0, 0, 1). Use to transform coordinates in geometry. Only present if geometry=paths is passed
relativeTransform: Transform;
// Whether or not this node clip content outside of its bounds
clipsContent: boolean;
// Whether this layer uses auto-layout to position its children.
// default: NONE
layoutMode?: string;
// Whether the primary axis has a fixed length (determined by the user) or an automatic length (determined by the layout engine). This property is only applicable for auto-layout frames.
// default: AUTO
primaryAxisSizingMode?: string;
// Whether the counter axis has a fixed length (determined by the user) or an automatic length (determined by the layout engine). This property is only applicable for auto-layout frames.
// default: AUTO
counterAxisSizingMode?: string;
// Determines how the auto-layout frame’s children should be aligned in the primary axis direction. This property is only applicable for auto-layout frames.
// default: MIN
primaryAxisAlignItems?: string;
// Determines how the auto-layout frame’s children should be aligned in the counter axis direction. This property is only applicable for auto-layout frames.
// default: MIN
counterAxisAlignItems?: string;
// The padding between the left border of the frame and its children. This property is only applicable for auto-layout frames.
// default: 0
paddingLeft?: number;
// The padding between the right border of the frame and its children. This property is only applicable for auto-layout frames.
// default: 0
paddingRight?: number;
// The padding between the top border of the frame and its children. This property is only applicable for auto-layout frames.
// default: 0
paddingTop?: number;
// The padding between the bottom border of the frame and its children. This property is only applicable for auto-layout frames.
// default: 0
paddingBottom?: number;
// The horizontal padding between the borders of the frame and its children. This property is only applicable for auto-layout frames. Deprecated in favor of setting individual paddings.
// default: 0
horizontalPadding?: number;
// The vertical padding between the borders of the frame and its children. This property is only applicable for auto-layout frames. Deprecated in favor of setting individual paddings.
// default: 0
verticalPadding?: number;
// The distance between children of the frame. This property is only applicable for auto-layout frames.
// default: 0
itemSpacing?: number;
// default: []
layoutGrids: LayoutGrid[];
// Defines the scrolling behavior of the frame, if there exist contents outside of the frame boundaries. The frame can either scroll vertically, horizontally, or in both directions to the extents of the content contained within it. This behavior can be observed in a prototype.
// default: NONE
overflowDirection?: string;
// An array of effects attached to this node (see effects section for more details)
// default: []
effects?: Effect[];
// Does this node mask sibling nodes in front of it?
// default: false
isMask?: boolean;
// Does this mask ignore fill style (like gradients) and effects?
// default: false
isMaskOutline?: boolean;
}
interface GroupNode extends Omit<FrameNode, "type"> {
type: "GROUP";
}
interface VectorNode extends Node {
type: "VECTOR";
// If true, layer is locked and cannot be edited
// default: false
locked?: boolean;
// An array of export settings representing images to export from the node
// default: []
exportSettings?: ExportSetting[];
// How this node blends with nodes behind it in the scene (see blend mode section for more details)
blendMode: BlendMode;
// Keep height and width constrained to same ratio
// default: false
preserveRatio?: boolean;
// Determines if the layer should stretch along the parent’s counter axis. This property is only provided for direct children of auto-layout frames.
layoutAlign: string;
// This property is applicable only for direct children of auto-layout frames, ignored otherwise. Determines whether a layer should stretch along the parent’s primary axis. A 0 corresponds to a fixed size and 1 corresponds to stretch
// default: 0
layoutGrow?: number;
// Horizontal and vertical layout constraints for node
constraints: LayoutConstraint;
// Node ID of node to transition to in prototyping
// default: null
transitionNodeID?: string;
// The duration of the prototyping transition on this node (in milliseconds)
// default: null
transitionDuration?: number;
// The easing curve used in the prototyping transition on this node
// default: null
transitionEasing?: EasingType;
// Opacity of the node
// default: 1
opacity?: number;
// Bounding box of the node in absolute space coordinates
absoluteBoundingBox: Rectangle;
// An array of effects attached to this node (see effects section for more details)
// default: []
effects?: Effect[];
// Width and height of element. This is different from the width and height of the bounding box in that the absolute bounding box represents the element after scaling and rotation. Only present if geometry=paths is passed
size: Vector;
// The top two rows of a matrix that represents the 2D transform of this node relative to its parent. The bottom row of the matrix is implicitly always (0, 0, 1). Use to transform coordinates in geometry. Only present if geometry=paths is passed
relativeTransform: Transform;
// Does this node mask sibling nodes in front of it?
// default: false
isMask?: boolean;
// An array of fill paints applied to the node
// default: []
fills?: Paint[];
// Only specified if parameter geometry=paths is used. An array of paths representing the object fill
fillGeometry: Path[];
// An array of stroke paints applied to the node
// default: []
strokes?: Paint[];
// The weight of strokes on the node
strokeWeight: number;
// A string enum with value of "NONE", "ROUND", "SQUARE", "LINE_ARROW", or "TRIANGLE_ARROW", describing the end caps of vector paths.
// default: "NONE"
strokeCap?: string;
// A string enum with value of "MITER", "BEVEL", or "ROUND", describing how corners in vector paths are rendered.
// default: "MITER"
strokeJoin?: string;
// An array of floating point numbers describing the pattern of dash length and gap lengths that the vector path follows. For example a value of [1, 2] indicates that the path has a dash of length 1 followed by a gap of length 2, repeated.
// default: []
strokeDashes?: number[];
// Only valid if strokeJoin is "MITER". The corner angle, in degrees, below which strokeJoin will be set to "BEVEL" to avoid super sharp corners. By default this is 28.96 degrees.
// default: 28.96
strokeMiterAngle?: number;
// Only specified if parameter geometry=paths is used. An array of paths representing the object stroke
strokeGeometry: Path[];
// Position of stroke relative to vector outline, as a string enum
strokeAlign: string;
// A mapping of a StyleType to style ID (see
styles: Record<StyleType, string>;
}
interface BooleanOperationNode extends Omit<VectorNode, "type"> {
type: "BOOLEAN_OPERATION";
// An array of nodes that are being boolean operated on
children: SceneNode[];
// A string enum with value of "UNION", "INTERSECT", "SUBTRACT", or "EXCLUDE" indicating the type of boolean operation applied
booleanOperation: string;
}
interface StarNode extends Omit<VectorNode, "type"> {
type: "STAR";
}
interface LineNode extends Omit<VectorNode, "type"> {
type: "LINE";
}
interface EllipseNode extends Omit<VectorNode, "type"> {
type: "ELLIPSE";
// Start and end angles of the ellipse measured clockwise from the x axis, plus the inner radius for donuts
arcData: ArcData;
}
interface RegularPolygonNode extends Omit<VectorNode, "type"> {
type: "REGULAR_POLYGON";
}
interface RectangleNode extends Omit<VectorNode, "type"> {
type: "RECTANGLE";
// Radius of each corner of the rectangle if a single radius is set for all corners
cornerRadius: number;
// Array of length 4 of the radius of each corner of the rectangle, starting in the top left and proceeding clockwise
rectangleCornerRadii: number[];
}
interface TextNode extends Omit<VectorNode, "type"> {
type: "TEXT";
// Text contained within a text box
characters: string;
// Style of text including font family and weight (see type style section for more information)
style: TypeStyle;
// Array with same number of elements as characters in text box, each element is a reference to the styleOverrideTable
// defined below and maps to the corresponding character in the characters field. Elements with value 0 have the default
// type style
characterStyleOverrides: number[];
// Map from ID to
styleOverrideTable: Record<number, TypeStyle>;
// An array with the same number of elements as lines in the text node, where lines are delimited by newline or paragraph separator characters. Each element in the array corresponds to the list type of a specific line. List types are represented as string enums with one of these possible values:
lineTypes: LineType[];
// An array with the same number of elements as lines in the text node, where lines are delimited by newline or paragraph separator characters. Each element in the array corresponds to the indentation level of a specific line.
lineIndentations: number[];
}
interface SliceNode extends Node {
type: "SLICE";
// An array of export settings representing images to export from this node
exportSettings: ExportSetting[];
// Bounding box of the node in absolute space coordinates
absoluteBoundingBox: Rectangle;
// Width and height of element. This is different from the width and height of the bounding box in that the absolute bounding box represents the element after scaling and rotation. Only present if geometry=paths is passed
size: Vector;
// The top two rows of a matrix that represents the 2D transform of this node relative to its parent. The bottom row of the matrix is implicitly always (0, 0, 1). Use to transform coordinates in geometry. Only present if geometry=paths is passed
relativeTransform: Transform;
}
interface ComponentNode extends Omit<FrameNode, "type"> {
type: "COMPONENT";
}
interface ComponentSetNode extends Omit<FrameNode, "type"> {
type: "COMPONENT_SET";
}
interface InstanceNode extends Omit<FrameNode, "type"> {
type: "INSTANCE";
// ID of component that this instance came from, refers to
componentId: string;
}
interface StickyNode extends Node {
type: "STICKY";
// Bounding box of the node in absolute space coordinates
absoluteBoundingBox: Rectangle;
// If true, author name is visible.
// default: false
authorVisible?: boolean;
// Background color of the canvas.
backgroundColor: Color;
// How this node blends with nodes behind it in the scene (see blend mode section for more details)
blendMode: BlendMode;
// Text contained within a text box
characters: string;
// An array of effects attached to this node (see effects section for more details)
// default: []
effects?: Effect[];
// An array of export settings representing images to export from the node
// default: []
exportSettings?: ExportSetting[];
// An array of fill paints applied to the node
// default: []
fills?: Paint[];
// Does this node mask sibling nodes in front of it?
// default: false
isMask?: boolean;
// If true, sticky is locked and cannot be edited
// default: false
locked?: boolean;
// Overall opacity of paint (colors within the paint can also have opacity values which would blend with this)
opacity: number;
// The top two rows of a matrix that represents the 2D transform of this node relative to its parent. The bottom row of the matrix is implicitly always (0, 0, 1). Use to transform coordinates in geometry. Only present if geometry=paths is passed
relativeTransform: Transform;
}
interface ShapeWithTextNode extends Node {
type: "SHAPE_WITH_TEXT";
// Bounding box of the node in absolute space coordinates
absoluteBoundingBox: Rectangle;
// Background color of the canvas.
backgroundColor: Color;
// How this node blends with nodes behind it in the scene (see blend mode section for more details)
blendMode: BlendMode;
// Text contained within a text box
characters: string;
// Radius of each corner of the rectangle if a single radius is set for all corners
cornerRadius: number;
// Array of length 4 of the radius of each corner of the rectangle, starting in the top left and proceeding clockwise
rectangleCornerRadii: number[];
// An array of effects attached to this node (see effects section for more details)
// default: []
effects?: Effect[];
// An array of export settings representing images to export from the node
// default: []
exportSettings?: ExportSetting[];
// An array of fill paints applied to the node
// default: []
fills?: Paint[];
// Does this node mask sibling nodes in front of it?
// default: false
isMask?: boolean;
// If true, shape-with-text is locked and cannot be edited
// default: false
locked?: boolean;
// Overall opacity of paint (colors within the paint can also have opacity values which would blend with this)
opacity: number;
// Shape-with-text geometric shape type.
shapeType: ShapeType;
// An array of stroke paints applied to the node
// default: []
strokes?: Paint[];
// The weight of strokes on the node
strokeWeight: number;
// A string enum with value of "NONE", "ROUND", "SQUARE", "LINE_ARROW", or "TRIANGLE_ARROW", describing the end caps of vector paths.
// default: "NONE"
strokeCap?: string;
// A string enum with value of "MITER", "BEVEL", or "ROUND", describing how corners in vector paths are rendered.
// default: "MITER"
strokeJoin?: string;
// An array of floating point numbers describing the pattern of dash length and gap lengths that the vector path follows. For example a value of [1, 2] indicates that the path has a dash of length 1 followed by a gap of length 2, repeated.
// default: []
strokeDashes?: number[];
// Position of stroke relative to vector outline, as a string enum
strokeAlign: string;
// The top two rows of a matrix that represents the 2D transform of this node relative to its parent. The bottom row of the matrix is implicitly always (0, 0, 1). Use to transform coordinates in geometry. Only present if geometry=paths is passed
relativeTransform: Transform;
}
interface ConnectorNode extends Node {
type: "CONNECTOR";
// Bounding box of the node in absolute space coordinates
absoluteBoundingBox: Rectangle;
// Background color of the canvas.
backgroundColor: Color;
// How this node blends with nodes behind it in the scene (see blend mode section for more details)
blendMode: BlendMode;
// Text contained within a text box
characters: string;
// Connector starting endpoint.
connectorStart: ConnectorEndpoint;
// Connector ending endpoint.
connectorEnd: ConnectorEndpoint;
// Connector line type.
connectorLineType: ConnectorLineType;
// Radius of each corner of the rectangle if a single radius is set for all corners
cornerRadius: number;
// Array of length 4 of the radius of each corner of the rectangle, starting in the top left and proceeding clockwise
rectangleCornerRadii: number[];
// An array of effects attached to this node (see effects section for more details)
// default: []
effects?: Effect[];
// An array of export settings representing images to export from the node
// default: []
exportSettings?: ExportSetting[];
// An array of fill paints applied to the node
// default: []
fills?: Paint[];
// Does this node mask sibling nodes in front of it?
// default: false
isMask?: boolean;
// If true, connector is locked and cannot be edited
// default: false
locked?: boolean;
// Overall opacity of paint (colors within the paint can also have opacity values which would blend with this)
opacity: number;
// An array of stroke paints applied to the node
// default: []
strokes?: Paint[];
// The weight of strokes on the node
strokeWeight: number;
// A string enum with value of "NONE", "ROUND", "SQUARE", "LINE_ARROW", or "TRIANGLE_ARROW", describing the end caps of vector paths.
// default: "NONE"
strokeCap?: string;
// A string enum with value of "MITER", "BEVEL", or "ROUND", describing how corners in vector paths are rendered.
// default: "MITER"
strokeJoin?: string;
// An array of floating point numbers describing the pattern of dash length and gap lengths that the vector path follows. For example a value of [1, 2] indicates that the path has a dash of length 1 followed by a gap of length 2, repeated.
// default: []
strokeDashes?: number[];
// Position of stroke relative to vector outline, as a string enum
strokeAlign: string;
// Connector text background.
textBackground: ConnectorTextBackground;
// The top two rows of a matrix that represents the 2D transform of this node relative to its parent. The bottom row of the matrix is implicitly always (0, 0, 1). Use to transform coordinates in geometry. Only present if geometry=paths is passed
relativeTransform: Transform;
}
type BaseNode = DocumentNode | CanvasNode | SceneNode;
type SceneNode =
| FrameNode
| GroupNode
| VectorNode
| BooleanOperationNode
| StarNode
| LineNode
| EllipseNode
| RegularPolygonNode
| RectangleNode
| TextNode
| SliceNode
| ComponentNode
| ComponentSetNode
| InstanceNode
| StickyNode
| ShapeWithTextNode
| ConnectorNode;
type NodeType = BaseNode["type"];
type Color = {
// Red channel value, between 0 and 1
r: number;
// Green channel value, between 0 and 1
g: number;
// Blue channel value, between 0 and 1
b: number;
// Alpha channel value, between 0 and 1
a: number;
};
type ExportSetting = {
// File suffix to append to all filenames
suffix: string;
// Image type, string enum that supports values
format: "JPG" | "PNG" | "SVG";
// Constraint that determines sizing of exported asset
constraint: Constraint;
};
type Constraint = {
// Type of constraint to apply; string enum with potential values below
type: "SCALE" | "WIDTH" | "HEIGHT";
// See
value: number;
};
type Rectangle = {
// X coordinate of top left corner of the rectangle
x: number;
// Y coordinate of top left corner of the rectangle
y: number;
// Width of the rectangle
width: number;
// Height of the rectangle
height: number;
};
type ArcData = {
// Start of the sweep in radians
startingAngle: number;
// End of the sweep in radians
endingAngle: number;
// Inner radius value between 0 and 1
innerRadius: number;
};
type BlendMode =
| "PASS_THROUGH"
| "NORMAL"
| "DARKEN"
| "MULTIPLY"
| "LINEAR_BURN"
| "COLOR_BURN"
| "LIGHTEN"
| "SCREEN"
| "LINEAR_DODGE"
| "COLOR_DODGE"
| "OVERLAY"
| "SOFT_LIGHT"
| "HARD_LIGHT"
| "DIFFERENCE"
| "EXCLUSION"
| "HUE"
| "SATURATION"
| "COLOR"
| "LUMINOSITY";
type EasingType =
| "EASE_IN"
| "EASE_OUT"
| "EASE_IN_AND_OUT"
| "LINEAR"
| "GENTLE_SPRING";
type FlowStartingPoint = {
// Unique identifier specifying the frame
nodeId: string;
// Name of flow
name: string;
};
type LayoutConstraint = {
// Vertical constraint as an enum
vertical: "TOP" | "BOTTOM" | "CENTER" | "TOP_BOTTOM" | "SCALE";
// Horizontal constraint as an enum
horizontal: "LEFT" | "RIGHT" | "CENTER" | "LEFT_RIGHT" | "SCALE";
};
type LayoutGrid = {
// Orientation of the grid as a string enum
pattern: "COLUMNS" | "ROWS" | "GRID";
// Width of column grid or height of row grid or square grid spacing
sectionSize: number;
// Is the grid currently visible?
visible: boolean;
// Color of the grid
color: Color;
// Positioning of grid as a string enum
alignment: "MIN" | "STRETCH" | "CENTER";
// Spacing in between columns and rows
gutterSize: number;
// Spacing before the first column or row
offset: number;
// Number of columns or rows
count: number;
};
type Effect = {
// Type of effect as a string enum
type: "INNER_SHADOW" | "DROP_SHADOW" | "LAYER_BLUR" | "BACKGROUND_BLUR";
// Is the effect active?
visible: boolean;
// Radius of the blur effect (applies to shadows as well)
radius: number;
// The color of the shadow
color: Color;
// Blend mode of the shadow
blendMode: BlendMode;
// How far the shadow is projected in the x and y directions
offset: Vector;
// How far the shadow spreads
// default: 0
spread?: number;
// Whether to show the shadow behind translucent or transparent pixels (applies only to drop shadows)
showShadowBehindNode: boolean;
};
type Hyperlink = {
// Type of hyperlink
type: "URL" | "NODE";
// URL being linked to, if URL type
url: string;
// ID of frame hyperlink points to, if NODE type
nodeID: string;
};
type DocumentationLink = {
// Should be a valid URI (e.g.
uri: string;
};
type Paint = {
// Type of paint as a string enum
type:
| "SOLID"
| "GRADIENT_LINEAR"
| "GRADIENT_RADIAL"
| "GRADIENT_ANGULAR"
| "GRADIENT_DIAMOND"
| "IMAGE"
| "EMOJI";
// Is the paint enabled?
// default: true
visible?: boolean;
// Overall opacity of paint (colors within the paint can also have opacity values which would blend with this)
// default: 1
opacity?: number;
// Solid color of the paint
color: Color;
// How this node blends with nodes behind it in the scene (see blend mode section for more details)
blendMode: BlendMode;
// This field contains three vectors, each of which are a position in normalized object space (normalized object space is if the top left corner of the bounding box of the object is (0, 0) and the bottom right is (1,1)). The first position corresponds to the start of the gradient (value 0 for the purposes of calculating gradient stops), the second position is the end of the gradient (value 1), and the third handle position determines the width of the gradient. See image examples below:
gradientHandlePositions: Vector[];
// Positions of key points along the gradient axis
// with the colors anchored there. Colors along the gradient
// are interpolated smoothly between neighboring gradient stops.
gradientStops: ColorStop[];
// Image scaling mode
scaleMode: "FILL" | "FIT" | "TILE" | "STRETCH";
// Affine transform applied to the image, only present if
imageTransform: Transform;
// Amount image is scaled by in tiling, only present if
scalingFactor: "TILE";
// Image rotation, in degrees.
rotation: number;
// A reference to an image embedded in this node. To download the image using this reference, use the
imageRef: string;
// Defines what image filters have been applied to this paint, if any. If this property is not defined, no filters have been applied.
// default: {}
filters?: ImageFilters;
// A reference to the GIF embedded in this node, if the image is a GIF. To download the image using this reference, use the
gifRef: string;
};
type Vector = {
// X coordinate of the vector
x: number;
// Y coordinate of the vector
y: number;
};
type Size = {
// the width of a size
width: number;
// the height of a size
height: number;
};
type Transform = [[number, number, number], [number, number, number]];
type ImageFilters = {
// default: 0
exposure?: number;
// default: 0
contrast?: number;
// default: 0
saturation?: number;
// default: 0
temperature?: number;
// default: 0
tint?: number;
// default: 0
highlights?: number;
// default: 0
shadows?: number;
};
type FrameOffset = {
// Unique id specifying the frame.
node_id: string;
// 2d vector offset within the frame.
node_offset: Vector;
};
type ColorStop = {
// Value between 0 and 1 representing position along gradient axis
position: number;
// Color attached to corresponding position
color: Color;
};
type LineType = "NONE" | "ORDERED" | "UNORDERED";
type TypeStyle = {
// Font family of text (standard name)
fontFamily: string;
// PostScript font name
fontPostScriptName: string;
// Space between paragraphs in px, 0 if not present
// default: 0
paragraphSpacing?: number;
// Paragraph indentation in px, 0 if not present
// default: 0
paragraphIndent?: number;
// Space between list items in px, 0 if not present
// default: 0
listSpacing?: number;
// Whether or not text is italicized
italic: boolean;
// Numeric font weight
fontWeight: number;
// Font size in px
fontSize: number;
// Text casing applied to the node, default is the original casing
// default: ORIGINAL
textCase?: "UPPER" | "LOWER" | "TITLE" | "SMALL_CAPS" | "SMALL_CAPS_FORCED";
// Text decoration applied to the node, default is none
// default: NONE
textDecoration?: "STRIKETHROUGH" | "UNDERLINE";
// Dimensions along which text will auto resize, default is that the text does not auto-resize.
// default: NONE
textAutoResize?: "WIDTH" | "HEIGHT" | "WIDTH_AND_HEIGHT";
// Horizontal text alignment as string enum
textAlignHorizontal: "LEFT" | "RIGHT" | "CENTER" | "JUSTIFIED";
// Vertical text alignment as string enum
textAlignVertical: "TOP" | "CENTER" | "BOTTOM";
// Space between characters in px
letterSpacing: number;
// Paints applied to characters
fills: Paint[];
// Link to a URL or frame
hyperlink: Hyperlink;
// A map of OpenType feature flags to 1 or 0, 1 if it is enabled and 0 if it is disabled. Note that some flags aren't reflected here. For example, SMCP (small caps) is still represented by the textCase field.
// default: {}
opentypeFlags?: Record<string, number>;
// Line height in px
lineHeightPx: number;
// Line height as a percentage of normal line height. This is deprecated; in a future version of the API only lineHeightPx and lineHeightPercentFontSize will be returned.
// default: 100
lineHeightPercent?: number;
// Line height as a percentage of the font size. Only returned when lineHeightPercent is not 100.
lineHeightPercentFontSize: number;
// The unit of the line height value specified by the user.
lineHeightUnit: "PIXELS" | "FONT_SIZE_%" | "INTRINSIC_%";
};
type Component = {
// The key of the component
key: string;
// The name of the component
name: string;
// The description of the component as entered in the editor
description: string;
// The ID of the component set if the component belongs to one
componentSetId?: string;
// The documentation links for this component.
documentationLinks: DocumentationLink[];
};
type ComponentSet = {
// The key of the component set
key: string;
// The name of the component set
name: string;
// The description of the component set as entered in the editor
description: string;
};
type Style = {
// The key of the style
key: string;
// The name of the style
name: string;
// The description of the style
description: string;
// The type of style as string enum
style_type: StyleType;
};
type ShapeType = {
SQUARE: string;
ELLIPSE: string;
ROUNDED_RECTANGLE: string;
DIAMOND: string;
TRIANGLE_DOWN: string;
PARALLELOGRAM_RIGHT: string;
PARALLELOGRAM_LEFT: string;
};
type ConnectorEndpoint = {
// Canvas location as x & y coordinate.
position: Vector;
// Node ID this endpoint attaches to.
endpointNodeId: string;
// The magnet type is a string enum
magnet: ConnectorMagnet;
};
type ConnectorLineType = {
ELBOWED: string;
STRAIGHT: string;
};
type ConnectorTextBackground = {
// Radius of each corner of the rectangle if a single radius is set for all corners
cornerRadius: CornerRadius;
// An array of fill paints applied to the node
fills: Paint[];
};
type StyleType = "FILL" | "TEXT" | "EFFECT" | "GRID";
type ConnectorMagnet = "AUTO" | "TOP" | "BOTTOM" | "LEFT" | "RIGHT";
type Path = {
windingRule: "NONZERO" | "EVENODD";
path: string;
};
type CornerRadius = number[];