Overview
specs-schema organizes components and compositions specs. Each spec is written as two or three files: api, variants and examples into a components/<component name>/ or composition/<composition name>/ directory, respectively. Other generated files like styling are stored alongside but are not part of the formal spec.
Component
A component describes the instances wherever needed, including nested as an element inside another component, composed into another component’s slot, or arranged inside a composition. When a component is only allowed to be nested inside one specific parent, it’s a subcomponent shipped with the parent rather than independently resuable.
| File | Holds | Command | Contract |
|---|---|---|---|
api.yaml | anatomy, props, invalidPropCombinations | generate | ComponentApiDocument |
variants.yaml | layout, styles, content | generate | ComponentVariantsDocument |
examples.yaml | instances, slot content examples | generate | ComponentExamplesDocument |
styling.yaml | Component specific styling report | analyze | — |
analysis/ files | Catalogue-wide summaries derived from the specs above | analyze | — |
api file
api holds the anatomy, props, and the prop combinations that are invalid
anatomy: root: type: container <element name>: type: # text, glyph, container, nested instance, ... instanceOf: # reference to another componentprops: <prop name>: type: # boolean, string, slot, ... ...invalidPropCombinations: ...variants file
variants holds the default and varying layout structures, styles and content.
default: layout: # nested layout array structure - root: # top node is always `root` - <element name>: - <element name> ... elements: <element name>: # every element gets an entry styles: width: layoutSizingHorizontal: backgroundColor: ... # style properties vary by element type content: # literal or $binding to a prop children: # reference to a slot property propConfigurations: # for nested instancesvariants: # zero or more deltas from the default, applied in order - configurations: ... # key/value pairs, like disabled:true layout: ... # same schema as default, of a complete different tree elements: ... # same schema as default, for impacted elements onlyVariants are a sparse differential patch: only the differences are stored. The default variant is the complete baseline — every element fully described, with styles, content and layout. Every entry in variants stores only what a configuration of prop(s) changes about the layout, styles and/or content. A component’s resolved state is the default with every matching variant’s deltas applied in declaration order, which resolves the same way every time.
examples file
examples holds ready-made instances as well as examples of the component’s slot(s) (which are actually compositions themselves)
slotContentExamples: # fills of referenced slots in examples and defaults <fill name>: anatomy: root: type: container elements: root: content: # literal or $binding to a prop layout: - root: []instanceExamples: # ready-made instances of the component <example name>: componentId: # this component's own id — a ready-made instance of itself propConfigurations: ...images: <image key>: ...Slots cross all three files. A slot prop is declared in api.yaml, example content lives in examples.yaml, and bindings fill it in variants.yaml.
Composition
A composition is a page type, template, pattern, or other scaffold arranging component instances into a fixed structure. It has no props and isn’t reusable, since no other component or composition references it.
| File | Holds | Command | Contract |
|---|---|---|---|
api.yaml | anatomy, title, description | generate | CompositionApiDocument |
variants.yaml | elements, layout | generate | CompositionVariantsDocument |
examples.yaml | slotContent fills | generate | CompositionExamplesDocument |
api file
api.yaml holds the composition’s anatomy, plus the title and description a component’s api.yaml has no field for.
title: # optional, human-readable labeldescription: # optional, purpose and usage notesanatomy: root: type: container <element name>: type: # text, glyph, container, nested instance, ...variants file
variants.yaml holds elements and layout — the composition’s one, unvarying appearance.
elements: <element name>: # every element gets an entry styles: width: layoutSizingHorizontal: backgroundColor: ... # style properties vary by element type content: # literal or $binding to a prop children: # reference to a slot property propConfigurations: # for nested instanceslayout: # nested layout array structure - root: # top node is always `root` - <element name>: - <element name> ...A composition does not vary by prop configuration — it has no props — so there is no default/variants split here the way a component has one. elements and layout are the whole of it.
examples.yaml file
examples.yaml holds the composition’s named slotContent fills — content bundled alongside the primary content, each one its own anatomy+elements+layout triplet.
slotContent: <fill name>: anatomy: root: type: container elements: root: content: # literal or $binding to a prop layout: - root: []images: <image key>: ...Following a slot content fill crosses two files, not three. A composition has no prop to declare a slot. Named fills live in examples.yaml and bindings in variants.yaml — pointing at #/compositions/<name>/slotContent/<fill> rather than a component’s #/components/<name>/slotContentExamples/<fill>.
styles and content
Styles and content work the same way for an element in either kind — Elements is the same type whether it belongs to a component’s default/variants or a composition’s flat elements.
Styles are organized per element and take different shapes:
- Flat and wide — dozens like
width,layoutSizingHorizontal,textColorandbackgroundColor. - Deep —
typographygathers the text properties under one node that corresponds to a text style, whileeffectsandGradientValuealso have deep, sophisticated shapes. - Side- and corner-shaped —
paddingandstrokeWeightasSides;cornerRadiusisCornersthat can be single value or several addressable parts (like{ start:, end:, top:, bottom: }).
Style values can be a literal, a TokenReference, a PropBinding, or a Conditional. A composite token can be bound to typography and effects (Figma’s text and effect styles, respectively).
Content surfaces directly through primitives as well as nested components that wrap primitives in an API. Content is mostly two things: text strings and glyph by name, reaching an element through content as a literal or a $binding to a prop. Image content flows through as both backgroundImage properties on elements and source properties on components. References to image files are declared in examples.yaml.
All three content types — and the containers that scaffold layout — are frequently offered as components themselves too. An Icon component that wraps a glyph element (the simple vector) with props for size and color; a text primitive element or a Text component with props for style, size and color.
Layout
layout is a tree, and there is one per component, per composition, and per instance.
Slots
A slot is a prop a component exposes for content it does not define and is filled in one of either a:
- Default slot — often nested as children. Since many slots are default slots, their fills merge into consolidated layout trees of a composition merged into place.
- Named slot — bound explicitly through a
SlotContentRefinto the host component’s slot.
Slot references are recorded as slotContentExamples for a component or “actual” slotContent of a composition.
References
A spec points at things rather than repeating them, with five references. Each is stored as a value in one file and resolved somewhere else — so these are the paths to follow when reading a catalogue. <property> in the Found in column is most often children, content, visible or value.
| Reference | Found in | Value |
|---|---|---|
instanceOf | api.yaml at anatomy.<element>.instanceOf | A component key, as a plain string |
$ref | api.yaml and variants.yaml at anatomy.<element>.instanceOf | "#/subcomponents/<name>" |
$binding | variants.yaml at default.elements.<element>.<property>, and the same path under each entry of variants | "#/props/<prop>" |
$slotContent | variants.yaml at ...elements.<element>.examples | "#/components/<component>/slotContentExamples/<name>" |
$slotContent | examples.yaml at instanceExamples.<name>.propConfigurations.<slotProp> | "#/components/<component>/slotContentExamples/<name>" |
$token | ...elements.<element>.styles.<property> | A token name, alongside a $type |
Conventions
Conventions change the shape of the spec, not its formatting — the same Figma file produces different specs under different conventions. For a schema reader, the question each convention answers is which part of the spec looks different, not what a convention is in general (see Settings for that distinction):
| Convention | What it changes |
|---|---|
glyphs | whether a component is typed glyph with a resolved name, or an ordinary element |
subcomponents | whether one component becomes a parent with nested subcomponents, or stays flat |
codeOnlyProps | whether a prop reaches the spec at all |
naming | whether a key can be reversed back to its original layer name |
states | whether a variant prop emits a CSS pseudo-class or a data-* attribute |
A wrong convention costs more than a missing one. If DEFAULT_CONVENTIONS shipped a glyphs pattern your library doesn’t use, no component would match it and every icon would arrive as an ordinary element rather than a named glyph — output that looks complete, is wrong, and flags nothing. So a default can fill in a missing member of a convention you declared, but never a convention block: the object is empty so that nothing is claimed about your library until you claim it. The full per-platform treatment is at Conventions.
Package Exports
The package exports TypeScript types for every node in the schema, plus two runtime values:
import type { Component } from '@directededges/specs-schema';import { DEFAULT_CONVENTIONS, DEFAULT_SETTINGS } from '@directededges/specs-schema';DEFAULT_CONVENTIONS and DEFAULT_SETTINGS are the only runtime exports; everything else is type-only. Spreading DEFAULT_CONVENTIONS adds nothing, and that is what makes it safe to spread — it is the identity value for Conventions, so a consumer applies defaults the same way whether or not the library declares any.
Analysis reports
The schema affords analysis because it’s a declared graph, not loose prose — typed props, styled elements, and instanceOf/$binding/$token references that resolve the same way everywhere. specs analyze walks that graph catalogue-wide and writes the result into analysis/, answering questions no single spec can, such as which components share a prop (props.yaml) or a change’s blast radius before it’s made (dependencies.graph.yaml). The full report list and what each one summarizes is at Analyze.
See Also
- Component and Composition — the two spec kinds
- Conventions and Settings — the declarations that shape a run
- The guides — how to express a particular thing correctly in data, a page per topic: variant layering, slot constraints, consolidating props, data layout, render to Figma, and more