Skip to content

Subcomponents

Subcomponents are smaller components embedded within a parent component’s spec. They follow the same structure as a top-level Component but without metadata or nested subcomponents. An optional source field carries the Figma node identity needed for reverse-direction tooling.

type Subcomponent = Omit<Component, 'metadata' | 'subcomponents'> & {
source?: SubcomponentSource;
};
type Subcomponents = Record<string, Subcomponent>;

Structure

A Subcomponent contains:

PropertyTypeRequiredDescription
titlestringYesSubcomponent name
anatomyAnatomyYesElement map
propsPropsNoProp definitions
defaultVariantYesDefault variant
variantsVariant[]NoVariant overrides
invalidVariantCombinationsPropConfigurations[]NoInvalid prop combinations
sourceSubcomponentSourceNoFigma source identity for this subcomponent’s node

SubcomponentSource

PropertyTypeDescription
pageIdstringFigma page ID containing this subcomponent’s node
nodeIdstringFigma node ID for this subcomponent’s component node
nodeType'COMPONENT' | 'COMPONENT_SET' | 'FRAME'Figma node type
subcomponents:
formLabel:
title: Form / Label
source:
pageId: "790:6766"
nodeId: "1477:200"
nodeType: COMPONENT
anatomy:
root:
type: container
default:
layout:
- root
elements:
root: {}

Linking

Elements in the parent anatomy reference subcomponents via $ref:

anatomy:
label:
type: instance
instanceOf:
$ref: "#/subcomponents/formLabel"

The $ref is a JSON Pointer into the same spec document.

Detection

Subcomponent detection is controlled by config.processing.subcomponents:

OptionTypeDefaultDescription
scope'NESTED' | 'PAGE''NESTED'Where to search — within the component frame or across the entire page
matchstring[]['{C} / _ / {S}']Name patterns for matching. {C} = parent component name, {S} = subcomponent name
excludestring[]Patterns to exclude from matching

Further Reading