Code Connect availability and requirements
mainTo use Code Connect, your organization must meet the following criteria:
- Plan: Available on Organization and Enterprise plans.
- Seats: Requires a full Design or Dev Mode seat.
repository·main·Indexed 23 days ago
https://github.com/figma/code-connectA tool for connecting design system components in code with Figma, allowing Dev Mode to display production code snippets instead of autogenerated examples. It features template files for framework-agnostic mapping, property mapping, and a client for interacting with the Figma REST API. Supports multiple languages via template tags including TSX, HTML, Swift, and Kotlin, and provides specialized helpers for React and Jetpack Compose.
To use Code Connect, your organization must meet the following criteria:
Code Connect is a tool that connects your design system components in code with your design system in Figma. It allows Figma's Dev Mode to display true-to-production code snippets instead of autogenerated examples.
Key capabilities include:
This helps drive consistent and correct adoption of a design system across both design and engineering teams.
Template files are the recommended, framework-agnostic way to use Code Connect. They provide full control over how components appear in Dev Mode and are the only method that will receive active maintenance moving forward.
Note on deprecation: Framework-specific parsers will no longer receive updates or support starting August 17th, 2026. If you are currently using parser-based Code Connect, you should follow the migration guide to switch to template files.
To automate the connection of large numbers of icons, use the provided example scripts. You must provide a FIGMA_ACCESS_TOKEN environment variable, which can be set directly in the command or provided via an .env file.
To run the script using npx tsx:
FIGMA_ACCESS_TOKEN=<my token> npx tsx import-icons.tsIf the token is already in an .env file, you can simply run:
# Assuming FIGMA_ACCESS_TOKEN is in .env
npx tsx import-icons.tsFIGMA_ACCESS_TOKEN=<my token> npx tsx import-icons.ts../docs/compose.md within the repository.The template generation logic converts Figma component property definitions into executable Code Connect code.
| Figma Property Type | Code Connect Method | Notes |
| :--- | :--- | :|
| BOOLEAN | figma.selectedInstance.getBoolean("name") | |
| TEXT | figma.selectedInstance.getString("name") | |
| VARIANT | figma.selectedInstance.getEnum("name", { ... }) | Used for multi-option variants. |
| VARIANT (Boolean) | figma.selectedInstance.getBoolean("name") | Used if variants are true/false, yes/no, etc. |
Property Name Normalization:
Property#123 $\rightarrow$ Property).camelCase and stripped of special characters.During the setup wizard, Code Connect automatically attempts to map your code component's props to Figma component properties. It uses a combination of name matching (fuzzy or via embeddings) and type compatibility to determine if a prop should be treated as a standard value or an Intrinsic.
The Matching Process:
Searcher. If componentMatchResults (embeddings) are available, they are prioritized over fuzzy matching.propSignature is compatible with the Figma property type.Intrinsic mapping. For example, a boolean prop in code might be mapped to a Figma variant property that acts as a boolean.Supported Intrinsic Kinds:
String: Mapped when the code prop is a string and the Figma property is Text.Boolean: Mapped when the code prop is false | true and the Figma property is a Boolean or a two-option Variant.Enum: Mapped when the code prop has multiple string/number options (e.g., 'primary' | 'secondary') and the Figma property is a Variant. The system uses generateValueMapping to align code enum values with Figma variant options.Instance: Mapped when the code prop signature is JSX-like (e.g., ReactElement, ReactNode) and the Figma property is an InstanceSwap.Code Connect uses ResultSection to represent the different types of content that can be emitted in a template. A ResultSectionList is an array of these sections.
| Type | Description |
|---|---|
CODE | A raw string of code. Contains code: string and optional nestedImports: string[]. |
INSTANCE | A Figma instance. Contains guid, symbolId, and optional resultSections or nestedImports. |
SLOT | A component slot. Contains propertyName and an optional guid. |
ERROR | An error state. Contains a message and an optional errorObject. |
These types are primarily used when calling methods like __render__() or when working with the TemplateStringResult returned by template tags.
Code Connect uses modifiers to bridge the gap between Figma components and your actual code. Modifiers allow you to define how a component's properties are retrieved and how it is rendered in code.
There are two primary types of modifiers:
getProps: Used to extract the props from a component instance.render: Used to define a render function that returns a JSX element, allowing Code Connect to map Figma properties to specific code implementations.When using the render modifier, the first argument must be a function (arrow function, function expression, or function declaration) that returns a single JSX element.
If no parser or label is explicitly defined in your figma.config.json, Code Connect uses heuristics to determine them by walking up the directory tree from your current location:
package.json contains react in dependencies or peerDependencies.package.json is present but no other supported web frameworks are detected.*.xcodeproj or Package.swift files exist.build.gradle.kts or build.gradle files exist.Code Connect looks for specific libraries in package.json to set a default label:
Angular if angular is a dependency/peer dependency.Vue if vue is a dependency/peer dependency.When setting up Code Connect, you can enable AI-powered property matching by setting useAi: true. This uses vector embeddings to find the best semantic matches between your code's props and Figma's component properties.
accessToken: A valid Figma access token.figmaUrl: The URL of the Figma file.apiUrlOverride (Optional): An override for the embeddings API endpoint.useAi is true, the CLI attempts to fetch embeddings for all unique matchable names (React props, Figma properties, and variant values).The preview command allows you to see how your Code Connect templates render with different component properties. There are two primary modes of operation:
--props): You provide exact property values. This is useful for testing a specific state.--all): The CLI attempts to enumerate and render all possible property combinations for the component.Constraints and Limits:
--props and --all at the same time.--all, the number of combinations is capped by --max-combinations (defaulting to 500) to prevent overwhelming the server. If a component exceeds this limit, the CLI will warn you and only render the first set of combinations.TYPE:name=value syntax (e.g., BOOLEAN:name=true).