1. Home
  2. /
  3. Figma-plugin-api
  4. /
  5. Group Selected Nodes

Group Selected Nodes - Figma-plugin-api Typing CST Test

Loading…

Group Selected Nodes — Figma-plugin-api Code

Groups the selected nodes together.

# figma_plugin/demo/code7.js
const nodes = figma.currentPage.selection
if(nodes.length > 0) {
	const g = figma.group(nodes, figma.currentPage)
	g.name = 'My Group'
}
figma.closePlugin('Grouped selection')

Figma-plugin-api Language Guide

The Figma Plugin API allows developers to create powerful plugins that extend Figma’s design environment. It provides programmatic access to Figma documents, nodes, components, and user interface elements, enabling automation, custom workflows, and interactive design tools.

Primary Use Cases

  • ▸Automating repetitive design tasks (e.g., resizing, renaming layers)
  • ▸Generating or modifying design content programmatically
  • ▸Design system enforcement and auditing
  • ▸Integrating external data (CSV, APIs) into Figma files
  • ▸Building interactive tools and utilities within Figma

Notable Features

  • ▸Full access to Figma document nodes and their properties
  • ▸Ability to create and manipulate components, frames, and shapes
  • ▸Plugin UI panels with HTML/CSS/JS
  • ▸Messaging between main and UI threads
  • ▸Supports async workflows and batch operations

Origin & Creator

Figma introduced the Plugin API in 2018 to allow the community to extend Figma’s capabilities with custom automation, tools, and integrations.

Industrial Note

The Figma Plugin API is widely used by UI/UX designers, product teams, and developers to automate repetitive tasks, generate assets, enforce design systems, and integrate with external tools or data sources.

Quick Explain

  • ▸The API provides a structured way to read and manipulate Figma documents.
  • ▸Plugins can create, modify, and delete nodes such as frames, rectangles, text, and components.
  • ▸It supports UI elements via HTML/CSS/JS panels rendered inside the Figma plugin window.
  • ▸Enables communication between plugin code (main thread) and UI thread (frontend panel).
  • ▸Supports asynchronous operations and event-driven architecture for responsive plugins.

Core Features

  • ▸Node manipulation (create, read, update, delete)
  • ▸Selection API to read user-selected nodes
  • ▸Event listeners for document changes
  • ▸Plugin UI API for custom interface panels
  • ▸Storage API for persisting plugin data

Learning Path

  • ▸Learn JavaScript or TypeScript basics
  • ▸Understand Figma document structure and node types
  • ▸Experiment with simple node manipulations
  • ▸Build interactive plugin UI panels
  • ▸Integrate external data and complex workflows

Practical Examples

  • ▸Automatically rename selected layers based on rules
  • ▸Generate charts or diagrams from CSV or JSON
  • ▸Batch export assets with custom naming conventions
  • ▸Plugin UI for selecting colors and applying palettes
  • ▸Audit document for design system compliance

Comparisons

  • ▸Figma Plugin API vs Sketch Plugins: cross-platform vs Mac-only
  • ▸Figma Plugin API vs FigJam Widgets: document manipulation vs collaborative widgets
  • ▸Figma Plugin API vs Lottie: design manipulation vs animations
  • ▸Figma Plugin API vs AnimXYZ: design tooling vs UI animation
  • ▸Figma Plugin API vs Figma Widgets: custom interactive tools vs static plugins

Strengths

  • ▸Deep integration with Figma’s document model
  • ▸Enables automation and productivity improvements
  • ▸Supports custom tool creation for teams and workflows
  • ▸Cross-platform (Figma desktop and browser apps)
  • ▸Rich plugin ecosystem with community contributions

Limitations

  • ▸Cannot execute arbitrary code outside Figma sandbox
  • ▸Limited access to system resources or local files
  • ▸Performance depends on document size and node operations
  • ▸UI customization constrained to plugin panels
  • ▸Requires understanding of asynchronous and event-driven JS

When NOT to Use

  • ▸For simple manual layer edits -> native Figma tools suffice
  • ▸Highly compute-intensive tasks -> may impact Figma performance
  • ▸Direct OS-level file manipulations -> Figma sandbox prevents
  • ▸Tasks outside Figma documents -> API not applicable
  • ▸Complex 3D animations -> better with dedicated tools or Lottie

Cheat Sheet

  • ▸figma.currentPage.selection -> get selected nodes
  • ▸figma.createRectangle()/createText() -> create new nodes
  • ▸node.fills / strokes -> access style properties
  • ▸figma.ui.postMessage() -> send message to UI thread
  • ▸figma.on('selectionchange', callback) -> listen to events

FAQ

  • ▸Do I need Figma desktop to develop plugins? -> No, web works too
  • ▸Can plugins access local files? -> Limited via user file pickers
  • ▸Are plugins cross-platform? -> Yes, work on desktop and web
  • ▸Can plugins run without UI? -> Yes, headless operations are supported
  • ▸Is TypeScript recommended? -> Yes, strongly typed API improves safety

30-Day Skill Plan

  • ▸Week 1: simple selection and node changes
  • ▸Week 2: create new nodes and shapes
  • ▸Week 3: add plugin UI with event handling
  • ▸Week 4: connect external APIs and dynamic data
  • ▸Week 5: optimize performance and publish plugin

Final Summary

  • ▸Figma Plugin API empowers developers to extend Figma with custom tools and automation.
  • ▸Enables deep document manipulation and workflow enhancements.
  • ▸Supports plugin UI for interactive controls.
  • ▸Allows integration with external data and services.
  • ▸Essential for creating productivity-focused design tooling inside Figma.

Project Structure

  • ▸manifest.json - plugin metadata and permissions
  • ▸code/ - main plugin logic (JS/TS)
  • ▸ui/ - optional HTML/CSS/JS panel
  • ▸assets/ - images, icons, fonts for plugin
  • ▸tests/ - automated or manual test scripts

Monetization

  • ▸Publish free/community plugins
  • ▸Offer premium enterprise plugins
  • ▸Custom internal tools for design teams
  • ▸Plugins as part of SaaS ecosystem
  • ▸Consulting or training for plugin development

Productivity Tips

  • ▸Reuse utility functions across plugins
  • ▸Batch node updates for performance
  • ▸Test small selections before full document
  • ▸Keep plugin UI minimal and focused
  • ▸Use community code examples for reference

Basic Concepts

  • ▸Node: any object in Figma (frame, component, shape, text)
  • ▸Selection: nodes currently selected by user
  • ▸Properties: width, height, fills, strokes, constraints, etc.
  • ▸UI panel: HTML/CSS/JS frontend for plugin interaction
  • ▸Message passing: communication between main and UI threads

Official Docs

  • ▸https://www.figma.com/plugin-docs/intro/
  • ▸https://www.figma.com/plugin-docs/api/

More Figma-plugin-api Typing Exercises

Select All FramesCreate a RectangleChange Text ContentDuplicate SelectionApply Drop ShadowResize Selected NodesCreate AutoLayout FrameRename Selected LayersChange Fill to Blue

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher