Skip to content

Specification

Version 0.40.0 — Draft

This document is the normative specification for the Specs document format: what a Specs document is, what a producer must write, what a consumer may rely on, and what a validator must reject.

It is the normative root of the schema documentation. The per-member reference — every property, its type, its examples — is published at spectacular.systems/schema and this document references it rather than restating it. Where prose here and a reference page disagree, this document governs for requirements; the JSON Schema governs for validation.

The audience is engineers and automated agents equally. Section numbers and rule identifiers (DSPEC-nn) are stable citation targets: cite a requirement by its rule ID where it has one, and by section otherwise.

Draft status. The requirements and the rule catalogue (§9) are written, and the reference validator and conformance suite exist (§10): @directededges/specs-schema-core checks a document against the schema for its kind and the catalogue’s validator-class rules, reporting every failure by rule identifier. A requirement marked unenforced is a statement of intent that nothing currently checks — a gap to close, not a claim to rely on.


1. Conventions

1.1 Requirement words

MUST, MUST NOT, REQUIRED, SHOULD, SHOULD NOT and MAY mean what RFC 2119 says, and only when written in capitals.

1.2 Enforcement notation

Every requirement ends with a parenthetical note naming what enforces it:

NoteMeaning
(schema: <file>)The named JSON Schema file rejects a violating document
(test: <file>)A test in packages/schema/tests/ fails
(DSPEC-nn)A semantic rule in the catalogue (§9) — a requirement JSON Schema cannot express
(producer)Binds producers; visible only in their output
(consumer)Binds consumers; visible only in their behaviour
(unenforced)Nothing currently checks it

A rule ID in the note means a validator implementing §9 checks it; the reference validator (§10) checks every validator-class rule except the two it names as uncheckable from a single document. A requirement that cannot be given an enforcement note does not belong in this document.

1.3 Terminology

  • A document is one YAML or JSON file claiming a Specs document kind (§2.1).
  • A component is the documented thing: title, anatomy, props, default, variants, and its example registries.
  • A composition is an assembly of component instances: anatomy, elements, layout, without props or variants of its own.
  • An element is one member of anatomy (structural) or elements (presentational); the two are keyed by the same names.
  • A key is the name under which an element, prop, variant, subcomponent, or registry entry is stored (§3).
  • A pointer is a single-member object whose key is a reserved $ marker and whose value addresses something else (§5).
  • A slot is a prop of type: slot, filled with structural content rather than a scalar.
  • A concern document is one of the split files (api, variants, examples) carrying one concern of a component or composition.

1.4 Conformance classes

ClassDefinitionKnown members
DocumentA file conforming to §2–§8Generated and authored specs
ProducerA tool that writes Specs documentsspecs generate, the Figma plugin, hand authoring
ConsumerA tool that reads Specs documents and acts on themPlatform transforms, the Figma render path, the docs generator
ValidatorA tool that decides conformance: schema plus §9@directededges/specs-schema-core (§10)

1.5 Scope and depth

Normativity is strongest at the top of a document and thins deliberately with depth:

  • Fully specified here: document kinds and identity (§2), identifiers (§3), configuration values and layering (§4), pointers (§5), slots, roles and composition (§6), extensions (§7), versioning (§8). These are the structures every producer and consumer must agree on.
  • Schema-and-reference governed: the leaf style vocabularies — styles, effects, typography, gradients, corners, sides. Their value grammars are enforced by styles.schema.json and documented per-member on the reference site; this document adds no prose requirements for them. A leaf vocabulary earns a section here only when it acquires a cross-member rule the schema cannot express.

1.6 Relationship to ADRs

Architectural decisions are recorded as numbered ADRs at spectacular.systems/adr. An ADR explains why a requirement exists; this document states the requirement. ADRs are not normative: a consumer MUST NOT treat an ADR as a requirement source — a rule an ADR describes binds only once stated here or in the schema (consumer). The Source column in §9 cites ADRs as provenance, not as authority.


2. Documents

2.1 Document kinds

A Specs document is exactly one of:

KindValidates againstCarries
Componentcomponent.schema.json#/definitions/ComponentA whole component
Component concerncomponent-concern.schema.jsonOne concern of one component
Composition concerncomposition-concern.schema.jsonOne concern of one composition
Components indexcomponents.schema.jsonA catalog of components
Conventionsconventions.schema.jsonA library’s naming and structural conventions
Settingssettings.schema.jsonA workspace’s run settings
Supplementalsupplemental.schema.jsonWhat a component needs beyond what the spec can carry
Guidelinesguidelines.schema.jsonThe rules whoever uses a component or a foundation must observe

A component MAY be written whole or split into concern documents; the two forms carry the same information (ADR-091, ADR-110).

The first six kinds are generated: a run writes them, and each records the Figma node it came from. The last two are authored: written by hand beside a spec, never by a run, and the distinction governs what they carry. An authored document has no Figma origin to record, so it carries meta (authorship and review status) where a generated document carries metadata (run and source provenance). The two member names are deliberately different, because the two blocks answer different questions (ADR-118).

The two authored kinds are siblings with no parent kind above them. Each declares its own header, verification and reference definitions rather than referencing a shared file, so each schema is readable and validatable on its own; the repetition between them is accepted deliberately (ADR-118).

They divide by audience, and by what kind of statement each makes:

  • Supplemental states a requirement on whoever builds the thing, and every entry names the schema surface that cannot carry it.
  • Guidelines states a rule binding whoever uses it. At a foundation’s scope that means how tokens, themes and raw values are applied across the catalogue — not what any one token is for, which is a description rather than a rule and has no home in either document.

Each is written at three scopes — one component, every component, one foundation — and the scopes are additive (DSPEC-56).

A foundation’s sections are a different vocabulary, not a subset. At the component scopes the section keys are anatomy, props, styles, slotComposition, events, accessibility, behavior, motion, layout, overrides and naming. At the foundation scope they are color, typography, layout, space, shape, elevation, motion and brand. Only layout and motion are in both. A document uses one vocabulary or the other and never both (DSPEC-64); because the two shared keys discriminate neither, the scope is ultimately the path, and a document using only those two is accepted at either.

A reference’s to names a token, a component, an item within one, or a workspace file. A checks reference naming a source file is legitimate and not a misuse — it is what an author knows and what re-verification after a regeneration needs. Resolution is not currently checked by anything (DSPEC-57 is unenforced): the target vocabulary admits four kinds with no stated way to tell them apart, so a resolver would either accept almost anything or reject legitimate targets. When one arrives, an unresolved target is a warning rather than an error, because an authored document legitimately references work not yet emitted.

2.2 Document identity

A whole-component document MUST NOT carry metadata.concern (schema: component.schema.json).

A concern document MUST carry metadata.concern, valued api, variants or examples, and MUST carry exactly the members its concern declares and nothing else — a concern document “requires what it carries and permits nothing else” (schema: component-concern.schema.json, composition-concern.schema.json; ADR-091, ADR-109).

The members per concern:

ConcernComponent documentComposition document
apititle, anatomy, props, invalidPropCombinations?, subcomponents?title?, description?, anatomy
variantsdefault, variants?, subcomponents?elements, layout
examplesslotContentExamples?, instanceExamples?, images?, subcomponents?slotContent?, images?

invalidPropCombinations belongs to the api concern, because a constraint on legal usage is contract, not manifestation (ADR-092).

2.3 Required members

A component document MUST carry title, anatomy and default (schema: component.schema.json).

Every generated document MUST carry metadata.source — the Figma page, node and node type it was generated from (schema: metadata.schema.json). A document without provenance cannot be regenerated or diffed against its origin.

An authored document (§2.1) MUST NOT carry metadata at all, and carries no provenance, because nothing generated it (schema: supplemental.schema.json, guidelines.schema.json). It MAY carry meta, whose status member is what distinguishes proposed content from ratified. Neither requires any member: a document carrying only a meta block, or nothing, is valid, because the scope path already names its subject (ADR-118).

An entry in a supplemental document MUST name the surface that cannot carry it, in schemaGap (schema: supplemental.schema.json). This is what bounds the document: a requirement the schema can express belongs in the spec, and an entry unable to name its gap is in the wrong file. A guidelines entry carries no schemaGap — a consumer rule is not an overlay on a schema surface — so that bound applies to one of the two authored kinds and the other relies on review.

A guidelines document MUST carry rules only, and MUST NOT carry per-token tables describing what each token is for (schema: guidelines.schema.json). A rule binds a reader; a description of a token does not, and mixing them buries the rules. Where per-token description belongs is not settled here — no document kind carries it, and the schema’s position is only that this one does not (ADR-118).

2.4 Run metadata

Facts about a run — author, lastUpdated, generator, schema, conventions, settings — describe the run, not any one component, and are optional on Metadata (ADR-089).

A document carrying only metadata.source MUST be independently valid, with no producer flag or out-of-band agreement needed to interpret it (schema: metadata.schema.json).

A producer that records run facts SHOULD record them once per run rather than identically on every document (producer, unenforced).

2.5 Closed property sets

Every definition declares additionalProperties: false unless it is an open map (§3.2). A document carrying an unrecognised key MUST be rejected (schema: all files).

This is deliberate and costly: every new member is a schema release. The alternative — ignoring unknown keys — makes a typo indistinguishable from a feature a consumer has not implemented.

2.6 Determinism

The same input under the same settings and conventions MUST produce an identical document (producer, unenforced). No field’s value may depend on run ordering, clock, or environment except the declared run metadata (§2.4).


3. Identifiers

3.1 Keys and the reserved prefix

Elements, props, variants, subcomponents, images, slot-content entries, instance examples and compositions are addressed by key.

A key MUST NOT begin with $ (schema: component.schema.json, via propertyNames). The $ prefix is reserved for pointer markers (§5.1), primitive-content markers (§6.3), and the $nested key (§5.4). A document key can never shadow a marker: the safe key grammar (§3.3) admits no leading $ either, so the two namespaces cannot collide (ADR-066, ADR-102).

3.2 Open maps

anatomy, props, elements, variants, subcomponents, images, slotContentExamples, instanceExamples and compositions are open, name-keyed maps.

Where the schema declares a key pattern it is ^[a-zA-Z0-9_-]+$ (schema: component.schema.json). The spelling of keys within that grammar is governed by the workspace’s settings.spec.keys, not by this specification.

All keys in one document MUST be written under one settings.spec.keys value (DSPEC-17).

3.3 Safe key grammar and name preservation

A producer deriving keys from Figma names operates under the declared source convention format.figmaKeys: NONE (default), SENTENCE, or TITLE (ADR-066).

Under SENTENCE or TITLE, a name is round-trip safe when it satisfies the character rules — ASCII letters and digits, single spaces, each word all-letters or all-digits, never beginning with a digit — and the casing pattern for the declared convention. The grammars are declared as SafeKeySentence and SafeKeyTitle (schema: component.schema.json).

A producer MUST record the original name in $extensions['com.figma'].name whenever the key cannot reconstruct it (DSPEC-18). A well-formed catalog that follows the safe grammar emits no such extensions at all.

Under NONE, no grammar is evaluated and reversal is undefined: a consumer rendering back to the source MUST use $extensions['com.figma'].name where present and the formatted key otherwise (DSPEC-19).

A consumer MUST NOT re-derive a name from a key when the original is recorded; the recorded name governs (consumer).

3.4 Object prop member names

An ObjectProp member name MUST NOT begin with $ (schema: component.schema.json) and MUST NOT contain the platform’s declared objectProps.separator (DSPEC-13; ADR-111). The first rule is what keeps a member-keyed object value distinguishable from every pointer form; the second is what keeps folding reversible.


4. Values and layering

4.1 Scalars

A scalar is a string, number or boolean — the Scalar definition. It deliberately excludes null, whose meaning is defined per site (§4.2).

4.1a An absent style key resolves to its declared default

Every property of Styles declares a default in styles.schema.json. A style key absent from an element resolves to that default, and a consumer MUST use it rather than substituting a platform convention of its own (DSPEC-44).

The declaration is by key presence, not truthiness: 19 of the 46 properties declare default: null, meaning apply nothing. That is a decision, and it is distinct from a property carrying no default keyword at all, which would mean nobody has decided.

A declared default is always a literal — never a TokenReference, PropBinding or Conditional, even where the property’s value union admits them (DSPEC-45). A default is what a reader assumes in the absence of any authored value, so it cannot itself require resolution.

A default answers only one of three reasons a key can be absent. A key may also be absent because a variant inherits it under layering (§4.4), or because its element type cannot carry it. Nothing in a document marks which applies, and the three are not distinguishable by a consumer reading one document. This specification does not yet resolve that; see mappings/DEFAULTS.md.

4.1b An absent composite member resolves to its declared default

Eight style properties resolve to a composite object — Sides, Corners, ItemSpacing, Effects, Shadow, Typography, ColorObject, ImageValue. A member of one of those objects absent from a document resolves to that member’s declared default, read the same way §4.1a reads a property’s, and a consumer MUST use it rather than substituting a platform convention of its own (DSPEC-52).

A member default is conditional on its containing object being present. Typography.textCase → "ORIGINAL" states what an inline typography object with no textCase means; what an absent typography means is styles.typography’s own default (§4.1a).

An optional member declares a default where its own schema can express the value an absent member carries. Eight do not, and an absent default keeps its §4.1a meaning of undeclared: four because the member means “nothing of this kind applies” and its schema admits no null to say so, three because no literal follows from the member’s own meaning, and one because automatic leading is spelled two ways in the contract (schema: styles.schema.json; DSPEC-52).

A required member declares no default (DSPEC-53). It cannot be absent, so a default there answers a question no document can ask.

Where a style property’s value may be written either as a scalar or as the composite that expands it — padding, strokeWeight, cornerRadius, itemSpacing — the property’s own default and its composite’s member defaults MUST agree (DSPEC-52). Sides serves both padding and strokeWeight, so its member defaults are declared once and are true by both paths.

4.2 null means unset

In a prop configuration, null under a prop key means the prop is unset in that configuration. It is a value, not an absence: an absent key inherits from the layer beneath; a null key overrides an inherited value with “no value” (ADR-080; schema: component.schema.json).

null is meaningful only under a nullable prop (DSPEC-12).

A configuration key MUST name a prop declared in the component’s props (DSPEC-11). Nothing outside the value may need to be consulted to interpret it — in particular, a consumer MUST NOT resolve a configuration by reading $extensions (consumer; ADR-080).

4.3 Configuration value forms

The value of one prop configuration entry (PropConfigurationValue) is one of: a scalar; null; a PropBinding (§5.1); a SlotContentRef under a slot-prop key (§5.1); an ImageBinding under an image-prop key; or a member-keyed ObjectPropValue under an object-prop key (schema: component.schema.json; ADR-049, ADR-063, ADR-080, ADR-111).

An InstanceExample configuration value is the deliberate subset without PropBinding and ImageBinding: an instance example is a documented configuration, not a live data flow (schema: component.schema.json; ADR-048).

4.4 Variant layering

default is the base variant; each entry in variants layers over it. A variant’s elements override the default’s per element and per style key; absent means inherited (schema: component.schema.json). The null-unset rule (§4.2) is what makes an explicit removal expressible under layering.

4.5 Closed value sets

A value whose admitted values are a fixed, known list is a closed value set.

A closed value set MUST be declared as oneOf branches of const, one branch per admitted value, and MUST NOT be declared as a bare enum array (DSPEC-48). Every branch MUST carry a description, or a title where the value itself is the whole meaning, stating what choosing that value does (DSPEC-49).

JSON Schema provides no keyword for annotating an individual member of an enum, in any draft. The branch form is the pattern the specification project endorsed in place of one, and it is what makes an option’s meaning readable by a consumer of the schema rather than only by a reader of the reference pages (ADR-114).

No value may satisfy two branches of the same oneOf (DSPEC-50). oneOf requires exactly one branch to match, so a const branch placed beside an open branch admitting that value’s own type rejects the value it was added to describe: the admitted values fail validation and unadmitted ones pass. Where a closed set must coexist with other forms — a token reference, a null, a sentinel — the branches MUST remain disjoint, which they are whenever they differ by JSON type.

A title is optional. It names the option where the value does not already name itself, as a numeric sentinel or an external identifier does not. It MUST NOT restate the value.

4.6 The mixed sentinel

A text layer whose characters differ has no single value for a type property. A producer that encounters one MUST record the string mixed, referencing MixedValue in styles.schema.json, rather than choosing one of the varying values (producer).

The sentinel is not a value. A consumer MUST apply nothing for it, and MUST NOT substitute one of the varying values or a platform default (DSPEC-51). Every binding declares it unsupported for this reason, which is the one disposition that states a deliberate non-realisation rather than a gap (§11.1).

Its purpose is to be visible. A mixed value reports that the source design mixes values within one layer, which is a thing to fix in the design rather than a thing to render. A producer SHOULD warn when it records one (producer, unenforced).

4.7 A theme selection is recorded where it was made and inherits down the element tree

Element.themes maps a token group name to the theme selected for that group (schema: component.schema.json; ADR-123). A token resolves to a different value under a different theme, and which theme applies is a fact of the element rather than of the token. The key names the group and the value names the theme, both as the token source spells them: a group name is not a key under §3 and is not formatted to spec.keys, because it must match the group segment of the TokenReference.$token paths the selection governs (DSPEC-73).

A producer MUST write a key only on the element that explicitly selected a theme for that group, and MUST NOT write the effective selection onto descendants (DSPEC-74). An absent key therefore means inherit, which is distinct from §4.1a’s declared default — there is no default at this site to fall back to.

A null value selects nothing for that group, and a consumer MUST drop the key from the effective set rather than carry it as a selection (DSPEC-78). This is §4.2’s distinction at a second site: an absent key inherits from the layer beneath, where a null key overrides the inherited selection with no selection. Every element selects nothing for every group until something says otherwise, so a null is that baseline written down — which is what lets a layering variant return an element to it.

null is a layering instruction and nothing else. A producer MUST NOT write one where no layer beneath it selects that group — in a default variant, in a composition, or in a slot fill (DSPEC-79). It says nothing at those sites: there is no selection to withdraw, and an element that selects nothing is written by omitting the key. Nor does it act on tree position: a descendant that writes null still resolves against its ancestors, which is what omitting the key already does, so the two are indistinguishable in the resolved state and on the canvas alike.

A consumer MUST resolve an element’s effective themes by merging its own keys over those of its ancestors, through nested instance boundaries, with the nearest selection winning per group (DSPEC-75). No document states the effective set.

A producer MUST write an explicit selection even where the selected theme is the group’s default theme (DSPEC-76). The two are not equivalent: an explicit selection holds inside a differently themed ancestor, where an absent key would inherit.

A producer MUST NOT write a key that is not a group name — a group identifier that resolves to no name is omitted rather than recorded raw (DSPEC-77), which is what makes the match against $token paths total rather than conditional. Group and theme names are open strings; the token source owns that vocabulary, and no validator checks a value against it (§10).

An InstanceExample MAY carry its own themes, which selects for the example instance and not for the component instantiated inside it — the distinction styles draws on the same type (§5.4). A consumer MUST resolve an example’s effective themes by merging the example’s map over the instantiated component’s, nearest selection winning per group, exactly as DSPEC-75 requires for elements (DSPEC-81). Without it an example reaches a theme only through the variant its propConfigurations select, so one configuration could not be presented under two themes.

A group name MUST come from a token source the producer’s workspace holds, never from the document’s source file alone (DSPEC-80). A file outlives the libraries it consumes: a group renamed and republished leaves the file answering under the name it last synced, and a file may reference groups no library the workspace holds has ever published. Both yield a key naming a group no consumer can resolve, and neither is detectable from inside the file — the file reports the retired name as confidently as a current one. So a producer resolves a group identifier against the sources it holds, and omits and reports anything that does not resolve (§11.2’s second permitted degradation). A producer with no sources to consult declares no opinion and filters nothing, which is not the same as holding none.

In a Figma-sourced spec a token group is a variable collection and a theme is one of its modes. That reading is provenance, in the sense of §7.2, and binds no consumer: a themes entry names a group and a theme, and resolving one requires nothing from any one design tool.


5. Pointers

5.1 Pointer forms

A pointer is a single-member object discriminated by its reserved key:

MarkerDefinitionAddressesShape
$refSubcomponentRefA subcomponent in the same document#/subcomponents/<key>
$refElementTypeRefAn external element typeURI reference
$bindingPropBindingA prop of the declaring component#/props/<key>
$slotContentSlotContentRefA slot-content entry (§6.4)JSON Pointer
$imageImageValueAn entry in the images registryregistry key
$tokenTokenReferenceA design tokentoken path

The branches of every pointer-bearing union are structurally unambiguous: each form is discriminated by its marker, and scalars by JSON primitive type (ADR-049).

5.2 Resolution

A SubcomponentRef MUST match #/subcomponents/<key> (schema: component.schema.json, via pattern) and that key MUST exist in the document’s subcomponents (DSPEC-03).

A PropBinding MUST point at a prop key declared by the component whose document carries it (DSPEC-02).

A $slotContent pointer MUST resolve to something carrying anatomy + elements + layout — a SlotContent entry or a Composition — reachable at its JSON Pointer path (DSPEC-01; ADR-046). The pointer names the act of filling a slot, not the target’s type.

An $image reference MUST resolve to an entry in the carrying document’s images registry, including before the entry’s bytes are resolved — an unresolved registry entry is valid; a dangling reference is not (DSPEC-14; ADR-063).

A validator MUST reject a document with an unresolvable pointer. JSON Schema cannot check this — a pointer’s payload is a string and its target may be in another document — so these are catalogue rules, not schema constraints.

The exception is ElementTypeRef: its $ref targets an arbitrary external URI, and resolution is entirely a consumer concern. A validator is not expected to fetch or verify it (ADR-012).

5.3 The reference graph

Composed content forms a graph: each filled slot points at another slotContentExamples or Composition.slotContent entry, which recurses with its own fills. Structure is shared by reference, never duplicated inline (ADR-052; producer).

Following $slotContent references MUST NOT lead back to where it started (DSPEC-20).

5.4 Nested paths

propConfigurations.$nested carries path-addressed configuration of nested descendant instances. A path is an ordered list of instanceOf element keys, descending instance to instance; the final key is the configured instance, located by direct element-key lookup — never container or layout layers (DSPEC-04; ADR-052).

A path MUST NOT descend through a slot fill: a filled slot is a reference, handled by recursion into the target entry’s own $nested paths. Every segment is therefore an instanceOf key, and each path spans only the hops to the next composed slot (DSPEC-05; ADR-052).

InstanceExample.propConfigurations does not accept $nested: deep configuration lives in slotContentExamples (schema: component.schema.json).

InstanceExample.styles is the example instance’s own box, not its content’s: a producer records it only when the instance declares a non-HUG horizontal sizing — layoutSizingHorizontal: 'FIXED' with width in raw px — and omits it for an instance left at its component’s natural size (DSPEC-65; ADR-124). A rendering consumer applies these styles to the instantiated example after configuration and content fills (DSPEC-66; ADR-124).

instanceExamples wraps its named items with the set-level orientation (ADR-125). A rendering consumer lays the examples out along the declared axis, and treats an absent orientation as VERTICAL (DSPEC-75).


6. Slots, roles and composition

6.1 Slot acceptance — anyOf

A SlotProp.anyOf is the one list of a slot’s accepted content: component names from the library’s own namespace, and reserved primitive markers (§6.3). Absence means unconstrained — any component, no primitive (ADR-102).

A primitive marker joins an anyOf that already names at least one component; it never constitutes one. anyOf: [$text] says only text may fill the slot — narrower than an absent anyOf — so a producer MUST NOT emit a marker-only anyOf for a slot whose design stated no constraint (DSPEC-08; ADR-102).

6.2 Default slot

SlotProp.defaultSlot: true marks the component’s designated default slot, resolved from the library’s specs.slots.default.match convention at generation time. At most one SlotProp per component MAY be true (DSPEC-06; ADR-099).

When true, an authored example may nest a filling instance as a plain child element instead of an explicit SlotContentRef (ADR-099).

6.3 Primitive content and contentStyles

The reserved markers $text and $glyph name the primitive kinds a slot accepts. The names are ElementType’s: type: text on an anatomy item and $text in anyOf are the same concept (ADR-102).

Formatting for primitive fills lives under the matching key of the slot element’s contentStyles. A slot element is one typed slot — or one whose children bind to a slot prop, which is how a producer writes a default slot’s host: the anatomy says container, the binding says slot. contentStyles is meaningful only on a slot element, and its keys SHOULD agree with that slot’s anyOf markers (DSPEC-07; ADR-102).

A component fill is formatted by the component it instantiates: a consumer rendering one applies the instance’s styles and MUST discard the slot’s contentStyles rather than cascading it (consumer; ADR-102).

6.4 Content registries

Component.slotContentExamples and Composition.slotContent hold named SlotContent entries — the anonymous anatomy + elements + layout triplet. Entries are slot-agnostic: binding to a slot happens at the reference site, not the entry (ADR-047).

A producer MUST deduplicate registry entries by structural equality, storing each distinct fill once (DSPEC-15; ADR-047). The same rule applies to the images registry: each distinct image is stored once and referenced many times (DSPEC-16; ADR-063).

Registry entries and SlotBinding.examples are examples, not contracts: they carry no implementation obligation for code consumers (consumer; ADR-047).

6.5 Roles and actions

role names what an element is; actions name what activating it does (ADR-067, ADR-087). Both vocabularies are open strings published on the docs site; a consumer MUST ignore values it does not recognize — an unknown role or action is inert (consumer).

On an element the component owns, more than one role is an error; the array form is meaningful only on an element of type: instance, where each concept routes to whichever element of the composed component ascribes it (DSPEC-09; ADR-067).

$extensions['com.figma'].childRole records a role annotated on a layer that wrapper collapse folded into this element. It is deliberately not merged into role: the pair is what lets a renderer put each annotation back on the layer that carried it (ADR-104).

6.6 Grid slot hosts

A slot element MAY carry layoutMode: GRID, making the items composed into it the cells of a grid. The leaf style vocabulary is governed by styles.schema.json and the reference pages (§1.5); the rules here are the ones that cross a structural boundary, which is what earns them a section.

A producer MUST flatten a slot whose only child is a grid container named by the platform’s slotGrid convention: the slot takes that container’s layoutMode and track keys, the container is dropped, and the container’s children become the slot’s content (DSPEC-71; ADR-122). The flatten exists because a design tool may forbid grid layout on a slot frame while the contract does not, so the same intent arrives one layer deeper than the contract records it.

The container must be the slot’s only child. A slot holding it beside anything else is holding content rather than declaring a layout, and a producer MUST leave such a container as an ordinary element (DSPEC-71).

Where the platform declares no such convention, the container is ordinary slot content and no flatten occurs (producer).

A producer MUST run this flatten before wrapper collapse (§6.5). The flatten leaves a root wrapping one slot, which is the shape that collapse removes, so the two run in sequence on a grid slot and a producer that reverses them leaves a wrapper standing (DSPEC-71).

Wrapper collapse distributes a merged element’s styles by what each style acts on. The track keys travel with the layoutMode they complete — a mode without them declares a layout it cannot perform — and when that mode is GRID the parent-layout group goes to the slot box alone rather than to both boxes (DSPEC-72; ADR-083, ADR-122). The both-boxes rule rests on those keys being near no-ops on a box holding exactly one child, which holds for a stacking axis and fails for a templated one: a lone child in a three-track grid occupies one track.


7. Extensions

7.1 Namespacing

Platform-specific data lives under $extensions, keyed by reverse-DNS namespace (ADR-026). This specification defines one namespace: com.figma, carrying extraction provenance.

Openness differs by site, and both readings are deliberate:

  • Prop extensions are open: PropExtensions accepts unknown reverse-DNS keys, and unknown fields within a known platform’s extension object. A consumer or validator MUST accept them rather than reject (DSPEC-31; ADR-026). A new platform’s data MUST be added as a new reverse-DNS-keyed member, never as a top-level property on the prop type (DSPEC-30; ADR-026).
  • Element and anatomy extensions are closed: their $extensions declarations reject undefined namespaces (schema: component.schema.json). A new namespace there is a schema release.

7.2 Extensions are provenance, not contract

$extensions['com.figma'] records how a document came to be, so a producer can render it back to its origin: preserved names (§3.3), folded flat prop names (ADR-111), promotion residue (ADR-074, ADR-084), collapsed-layer roles (§6.5).

A consumer that emits platform code MUST NOT read $extensions['com.figma']: the spec contract is the whole input for emission, and a spec that requires Figma decoding to emit correctly is a producer defect (DSPEC-21; consumer).


8. Versions

8.1 Versioning

This specification and the @directededges/specs-schema package share a version; the current version is 0.40.0. Pre-1.0, a minor release MAY break. Every breaking change MUST be recorded under ### Breaking in CHANGELOG.md with a migration note (test: none — unenforced).

8.2 Schema identity

Each schema file declares an $id of the form https://spectacular.systems/schema/<version>/<file> (schema: all files). The $id is an identifier, not a fetchable URL: the schema files are distributed in the @directededges/specs-schema npm package, and nothing is served at these URLs today. Resolve them locally from the package.

A released schema at a given $id MUST NOT change; a correction is a new version at a new $id (unenforced).

A producer records the schema version a document was written against in run metadata (metadata.schema; schema: metadata.schema.json).

8.3 Draft

The schema files declare JSON Schema draft-07; the decomposition keyword is definitions, not $defs. Migration to 2020-12 is not planned for 0.x.

8.4 Type and schema parity

The package publishes TypeScript types in types/ and JSON Schema in schema/ describing the same structure. Every type MUST have a corresponding schema definition and every definition a corresponding type (DSPEC-22; CONSTITUTION §I — test: SchemaTypeParity.test.ts). Correspondence is by name, under two conventions the test applies: a definition <X>StyleValue or <X>Value pairs with a type <X> or <X>Style, and the deliberate divergences — path-scoped narrowings and property-name vocabularies the schema cannot address, grammars TS cannot express, runtime-resolved TS-only shapes, deprecated schema-only forms — are enumerated with reasons in tests/parity-exclusions.ts.

The JSON Schema is authoritative for validating serialized documents; the TypeScript types are authoritative for compile-time consumption. Neither governs the other.


9. Rule catalogue

Semantic rules — requirements JSON Schema cannot express. Each rule binds the class named; a conforming validator checks every rule marked validator.

IDRuleClassSource
DSPEC-01A $slotContent pointer resolves to a reachable anatomy + elements + layout targetvalidator§5.2, ADR-046
DSPEC-02A $binding points at a prop key the declaring component’s props carriesvalidator§5.2, ADR-008/049
DSPEC-03A SubcomponentRef’s key exists in the document’s subcomponentsvalidator§5.2, ADR-030
DSPEC-04Every $nested path segment is an instanceOf element key, resolved by direct lookupvalidator§5.4, ADR-052
DSPEC-05A $nested path never descends through a slot fillvalidator§5.4, ADR-052
DSPEC-06At most one SlotProp per component carries defaultSlot: truevalidator§6.2, ADR-099
DSPEC-07contentStyles appears only on slot elements — typed slot, or slot-bound through children — keyed consistently with the slot’s markersvalidator§6.3, ADR-102
DSPEC-08A primitive marker never appears in a marker-only anyOfproducer§6.1, ADR-102
DSPEC-09An owned element carries at most one role; the array form appears only on instancesvalidator§6.5, ADR-067
DSPEC-11A configuration key names a prop declared in propsvalidator§4.2, ADR-080
DSPEC-12null appears only under a nullable propvalidator§4.2, ADR-080
DSPEC-13An ObjectProp member name does not contain the declared objectProps.separatorproducer§3.4, ADR-111
DSPEC-14Every $image reference resolves to an images registry entryvalidator§5.2, ADR-063
DSPEC-15slotContentExamples entries are deduplicated by structural equalityproducer§6.4, ADR-047
DSPEC-16images registry entries are deduplicated; one entry per distinct imageproducer§6.4, ADR-063
DSPEC-17All keys in one document follow one settings.spec.keys formatproducer§3.2, ADR-066
DSPEC-18$extensions['com.figma'].name is recorded whenever the key cannot reconstruct the nameproducer§3.3, ADR-066
DSPEC-19Reversal under NONE uses the recorded name where present, the key otherwiseconsumer§3.3, ADR-066
DSPEC-20Following $slotContent references never returns to the starting entryvalidator§5.3, ADR-052
DSPEC-21A code emitter reads no $extensions['com.figma'] memberconsumer§7.2
DSPEC-22Every TypeScript type has a schema definition and every definition a typepackage§8.4, CONSTITUTION §I
DSPEC-23A $token path uses . as its segment separator; the source’s own separator survives only in $extensions['com.figma'].nameproducer§5.1, ADR-006
DSPEC-24$type: "effects" on a token reference is a non-DTCG extension; a consumer treats it as non-portableconsumer§5.1, ADR-006
DSPEC-25A token reference’s origin is read from $extensions['com.figma'].collectionName: present means variable, absent means named styleconsumer§5.1, ADR-006
DSPEC-26An omitted settings.spec.tokens behaves identically to TOKEN; omitted default-bearing settings generally behave as their scaffolded defaults, and only feature-toggle members mean “off” when absentconsumer§2.1, ADR-007/035/112
DSPEC-27fillColor appears only on glyph and shape elements, textColor only on text elements; an instance’s colour overrides are the composed component’s to judgevalidator§6.3, ADR-013
DSPEC-28A ConditionExpression.operation is an open vocabulary; a consumer tolerates unrecognized operationsconsumerstyles reference, ADR-018
DSPEC-29compareTo is present for binary operations (equals, notEquals) and absent for unary ones (isNull, isNotNull)validatorstyles reference, ADR-018
DSPEC-30A new platform’s extension data is added as a reverse-DNS key on PropExtensions, never as a top-level prop memberproducer§7.1, ADR-026
DSPEC-31Unknown platform keys on PropExtensions, and unknown fields within a known platform’s prop extension, are accepted, not rejectedconsumer§7.1, ADR-026
DSPEC-32A Figma TEXT code-only property is emitted as type: "string"; numeric-looking content alone never infers a number — only the inferNumberProps convention, whose test every default and example must pass, may emit NumberPropproducer§2.6, ADR-027/029
DSPEC-33The code-only prop hierarchy is constant across all variants of a componentvalidator§4.4, ADR-027
DSPEC-34Content filling a slot with anyOf present is an instance of a named entry (or a permitted primitive, §6.1)validator§6.1, ADR-028/102
DSPEC-35The number of items filling a slot falls within its declared minChildren/maxChildrenvalidator§6.1, ADR-028 (fields renamed by ADR-056)
DSPEC-36A subcomponent candidate matching both a match and an exclude pattern is excluded, regardless of discovery sourceproducerconventions reference, ADR-031
DSPEC-37An empty variant is one whose layered diff from default contains no elements; settings.include.emptyVariants filters by exactly that definitionproducer§4.4, ADR-034
DSPEC-38metadata.schema.url resolves to the exact schema version named by metadata.schema.versionproducer§8.2, ADR-023
DSPEC-39When settings.spec.color is not OBJECT, every color-bearing value in the document is a string in that notationvalidator§2.6, ADR-043
DSPEC-40The length and order of a ColorObject’s components correspond to the channels of its colorSpacevalidatorstyles reference, ADR-009
DSPEC-41A platform binding declares a disposition for every property of Stylesbinding§11.1
DSPEC-42A platform binding declares its handling of each of the four style value formsbinding§11.1
DSPEC-43A degradation applies the spec’s own recorded fallback or applies nothing and warns; it never invents data the document does not carrybinding§11.2
DSPEC-44Every property of Styles declares a default, and its value validates against that property’s own schemapackage§4.1a
DSPEC-45A declared default is a literal, never a TokenReference, PropBinding or Conditionalpackage§4.1a
DSPEC-46A platform binding does not redeclare a style default; it cites the schema’sbinding§11.1
DSPEC-47Jointly resolved keys are stated as an ordered case table over a declared operand set, not as prosebinding§11.1
DSPEC-48A closed value set is declared as oneOf branches of const, never as a bare enum arraypackage§4.5, ADR-114
DSPEC-49Every branch of a closed value set carries a description or a title stating what choosing that option doespackage§4.5, ADR-114
DSPEC-50No value satisfies two branches of the same oneOf; in particular a const branch never sits beside an open branch admitting that value’s own typepackage§4.5, ADR-114
DSPEC-51A consumer applies nothing for a mixed value, and never substitutes one of the varying values or a platform defaultconsumer§4.6
DSPEC-52An optional member of a Styles composite type declares a default where its own schema can express the value an absent member carries, and any declared default validates against that member’s schemapackage§4.1b, ADR-116
DSPEC-53A required member of a Styles composite type declares no defaultpackage§4.1b, ADR-116
DSPEC-54A frame is an image asset only when its name matches images.match and it is a direct child of a page, or of a section that is itself a direct page child; a match at any other depth is not an assetproducerconventions reference, ADR-117
DSPEC-55A declared images.component requires a non-empty images.sourceProps, whose first entry is that component’s own source propvalidatorconventions reference, ADR-077/117
DSPEC-56A supplemental or guidelines entry at the catalogue scope and one at the component scope both apply; neither overrides the other, because an entry is a statement about a subject rather than a value at a keyconsumer§2.1, ADR-118
DSPEC-57A reference’s to names something that exists — a token, a component, an item within one, or a workspace file. A consumer that cannot resolve it reports a warning and continues, never an errorunenforced§2.3, ADR-118
DSPEC-58A schemaGap.path that is a JSON Schema pointer resolves against the schema file it namesvalidator§2.3, ADR-118
DSPEC-59An exporter emitting DSDS appends a guideline’s instead to its statement and never drops it, so no consumer receives a prohibition without its remedyproducer§2.1, ADR-118
DSPEC-60An exporter derives a token’s DSDS id from the workspace’s spec.tokens profile, normalizing per path segment only where that output is not a legal identifierproducer§2.1, ADR-118
DSPEC-61An exporter emits a token’s original path as name, unmodified, because the derived id folds case and punctuation and cannot be reversedproducer§2.1, ADR-118
DSPEC-62A directory under foundations/ is named from the foundation concern vocabulary; a document schema validates contents and cannot validate the path that selects itvalidator§2.1, ADR-118
DSPEC-63A guidelines document carries rules only, and no table describing what each token is forvalidator§2.3, ADR-118
DSPEC-64An authored document is keyed for one concern vocabulary or the other, never both; layout and motion are in each and discriminate neither, so the scope is the pathschema: supplemental.schema.json, guidelines.schema.json§2.1, ADR-118
DSPEC-65A producer MUST record InstanceExample.styles only for an example instance declaring non-HUG horizontal sizing — layoutSizingHorizontal: 'FIXED' with width in raw px — and MUST omit it otherwiseproducer§5.4, ADR-124
DSPEC-66A rendering consumer MUST apply InstanceExample.styles to the instantiated example after configuration and content fillsconsumer§5.4, ADR-124
DSPEC-67A rendering consumer MUST lay instance examples out along the declared InstanceExamples.orientation, treating an absent value as VERTICALconsumer§5.4, ADR-125
DSPEC-68A resolved styles block carries a non-null value for at most one of gridColumns and gridRows; a grid templates one axis and sizes the other by contentvalidatorstyles reference, ADR-122
DSPEC-69A variant layer that sets one of gridColumns or gridRows clears the other, written as an explicit null rather than omitted, since an omitted key inheritsproducerstyles reference, ADR-122
DSPEC-70A consumer reading both axes non-null treats gridColumns as the templated axis and reports gridRows as unsupported, rather than choosing either silentlyconsumerstyles reference, ADR-122
DSPEC-71A slot whose only child is a grid container named by the platform’s slotGrid convention takes that container’s grid, and the container’s children become the slot’s content; a container sharing the slot with anything else stays an ordinary elementproducer§6.6, ADR-122
DSPEC-72Wrapper collapse carries the grid track keys with the layoutMode they complete, and distributes that group to the slot box alone when the mode is GRIDproducer§6.6, ADR-083/122
DSPEC-73A themes key is a token group name as the token source spells it, unformatted by spec.keys, so it matches the group segment of the token paths the selection governsproducer§4.7, ADR-123
DSPEC-74A themes key is written only on the element that explicitly selected a theme for that group, never as the effective selection on descendantsproducer§4.7, ADR-123
DSPEC-75An element’s effective themes are its own themes keys merged over its ancestors’, through nested instance boundaries, nearest selection winning per groupconsumer§4.7, ADR-123
DSPEC-76An explicit selection is written even where it equals the group’s default theme, because it holds inside a differently themed ancestor where an absent key would inheritproducer§4.7, ADR-123
DSPEC-77A token group whose identifier resolves to no name is omitted from themes rather than recorded as a raw identifierproducer§4.7, ADR-123
DSPEC-78A null theme value selects nothing: a consumer drops the key from the effective set, and a layering variant writes null to remove a selection the layer beneath madeconsumer§4.7, ADR-123
DSPEC-79A null theme value is written only where a layer beneath selects that group — never in a default variant, a composition, or a slot fill, where an element that selects nothing omits the key insteadproducer§4.7, ADR-123

The reference validator (§10) implements every validator row except DSPEC-33 and DSPEC-63, whose single-document limits §10 states.

Rules DSPEC-23 through 40 were harvested from ADRs 001–045 in a systematic second pass; candidates citing fields that no longer exist (internal, iconNamePattern) or binding pipeline internals invisible in any document were excluded, and renamed fields are stated under their current names with the renaming ADR cited.

10. Validators and consumers

The reference validator and conformance suite live in packages/specs-schema-core (@directededges/specs-schema-core). The package is the normative answer to “does this document conform”: validateDocument(document, kind) runs the JSON Schema for the document’s kind (§2.1) and the rule catalogue’s validator-class rules (§9), and reports every failure by rule identifier — DSPEC-nn for a catalogue rule, schema for a JSON Schema failure. Formats (uri, uri-reference, date-time) are enforced, so the schema’s format constraints are checked rather than correct by inspection.

The schema a document validates against depends on its kind. A whole component validates against the Component definition in component.schema.json; a concern document validates against its file’s root, which carries the top-level choice over document kinds — validating against one definition inside the file would silently narrow the check to that kind. conventions.schema.json and settings.schema.json declare no root schema, so their main definitions are the targets.

The conformance suite is the package’s fixture corpus plus the test that runs it:

  • Positive fixtures — documents that MUST validate: each document kind, each in-document reference form, slots with primitive content and a default slot, roles and actions, extensions, and value forms the schema admits that generated corpora rarely write.
  • Negative fixtures — documents that MUST be rejected, each paired with the one rule it violates. The suite asserts the reported rules are exactly the paired rule, so a validator that rejects a fixture for the wrong reason — and a fixture that violates two rules — both fail.
  • Completeness — every validator-class row in §9 is implemented or named in the package’s UNCHECKED_RULES with its reason, and every implemented rule has a negative fixture. Adding a rule without either fails the suite.

Two validator-class rules are uncheckable from a single document and are declared as such in UNCHECKED_RULES: DSPEC-33, because what must stay constant across variants is producer behaviour across generation runs, which no single document records; and DSPEC-63, whose structural half guidelines.schema.json enforces and whose prose half — whether a statement describes rather than binds — no validator can judge.

Scope: the validator checks what one document states about itself. A pointer rooted in the workspace (#/components/…, <file>#/…) needs the rest of the workspace to resolve; specs validate checks those across files in its reference layer, and uses this package as its schema and catalogue engine.

The examples values in the schema files are validated against their enclosing definitions by packages/schema/tests/SchemaExamples.test.ts.

Consumer requirements stated above (DSPEC-19, DSPEC-21, §1.5, §4.2, §6.3, §6.4, §6.5) bind any tool reading Specs documents, whether or not a validator runs.

11. Platform bindings

§§2–8 say what a Specs document is. They do not say what any platform must do with one. A platform binding closes that gap: one document per platform, stating how that platform realises the schema.

Bindings live in mappings/ beside this document — mappings/FIGMA.md, mappings/REACT.md — and are generated from the declarations in mappings/bindings/<platform>.json.

11.1 What a binding declares

A binding MUST declare, for every property of Styles, one of four dispositions (DSPEC-41):

DispositionMeaning
boundRealised, and confirmed against an implementation
approximatedRealised with loss, and the loss is stated
unsupportedDeclared as not realised, with the resulting behaviour stated
unverifiedCoverage detected, mapping not confirmed by a human

A reader MAY rely on bound, approximated and unsupported. An unverified row asserts nothing — it records outstanding work, and a binding that is wholly unverified is a stub, not a specification.

Where several keys resolve jointly — no one key determining any one output — a binding MUST state the mapping as an ordered case table over a declared, finite operand set, not as prose. A sentence describing a decision procedure cannot be checked, and reads as determinism without being it. Each case carries a predicate and the exact outputs it emits; an empty output list is a claim, a missing one is an omission (DSPEC-47).

The predicate grammar reuses this specification’s ConditionExpression vocabulary — an operation with args — because operation is a deliberately open string (DSPEC-28). The operand space differs and the difference is declared, not glossed: a spec Conditional tests a PropBinding into #/props/*, while a binding case tests a style fact on self, parent, a named derived predicate, or the emitting context.

A binding MUST NOT redeclare a style default. What an absent key means is a property of the document, declared once in the schema (§4.1a), and a binding that restates it creates a second source free to disagree. A binding states what a platform does with a value; the value an absent key carries is not the platform’s choice (DSPEC-46).

A binding MUST also declare what it does with each of the four value forms a style may take — a literal, a TokenReference, a PropBinding, a Conditional (DSPEC-42). A disposition for padding means nothing without saying whether a Conditional padding is realised, approximated, or dropped.

A binding SHOULD declare dispositions for props, anatomy and elements, and layout. Where it does not, it MUST name the concept as undeclared so the absence is visible rather than implied.

11.2 Degradation

An approximated or unsupported disposition MUST state the resulting behaviour. “Not supported” alone is not a binding: a consumer needs to know whether the value is dropped silently, warned about, or substituted.

A binding MUST NOT describe a degradation that invents data the document does not carry. Where a platform cannot realise a value, the permitted behaviours are to apply the spec’s own recorded fallback, or to apply nothing and warn (DSPEC-43).

11.3 Direction

A binding MUST declare its direction. Figma is bidirectional — a document renders onto the canvas and is generated back from it — so its binding carries fidelity obligations both ways. The code platforms are emit-only, and a binding that does not say so implies a round trip that does not exist.

11.4 Bindings are not the implementation

A binding is a specification, not a description of one codebase. It is seeded from an implementation and continuously checked against it, but the declaration is authoritative: where they disagree, one of them is a defect, and the binding says which behaviour was intended.

This separation is what lets the binding be published from this repository while an implementation lives elsewhere, and what lets a second implementation of the same platform be judged conforming or not.