Schema
Spectactular’s schema organizes components and compositions into specs data that conforms to an explicit, predictable structure.
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.
A component is reusable and takes props. A composition is a page type, template, pattern, or other scaffold arranging component instances into a fixed structure — it has no props, and nothing else references it. Both are written by the generate command, and each file has a contract page carrying its properties and an example.
| File | Kind | Holds | Contract |
|---|---|---|---|
api.yaml | Component | anatomy, props, and the prop combinations that are invalid | Component API |
variants.yaml | Component | the default layout, styles and content, plus one delta per variant | Component Variants |
examples.yaml | Component | ready-made instances, slot content examples, and the image registry | Component Examples |
api.yaml | Composition | anatomy, plus the title and description a component’s api.yaml has no field for | Composition API |
variants.yaml | Composition | elements and layout — one unvarying appearance, with no default/variants split | Composition Variants |
examples.yaml | Composition | named slotContent fills bundled alongside the primary content | Composition Examples |
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: }). - Stacked — the four paint keys (
backgroundColor,fillColor,textColor,strokes) take a single value or an ordered list of them painted over each other, the bottom value first.
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.
For a component, 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.
For a composition, following a 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>.
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