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.

type Subcomponent = Omit<Component, 'metadata' | 'subcomponents'>;
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

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