Skip to content

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.

FileHoldsCommandContract
api.yamlanatomy, props, invalidPropCombinationsgenerateComponentApiDocument
variants.yamllayout, styles, contentgenerateComponentVariantsDocument
examples.yamlinstances, slot content examplesgenerateComponentExamplesDocument
styling.yamlComponent specific styling reportanalyze—
analysis/ filesCatalogue-wide summaries derived from the specs aboveanalyze—

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 component
props:
<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 instances
variants: # 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 only

Variants 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.

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:

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 SlotContentRef into 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.

ReferenceFound inValue
instanceOfapi.yaml at anatomy.<element>.instanceOfA component key, as a plain string
$refapi.yaml and variants.yaml at anatomy.<element>.instanceOf"#/subcomponents/<name>"
$bindingvariants.yaml at default.elements.<element>.<property>, and the same path under each entry of variants"#/props/<prop>"
$slotContentvariants.yaml at ...elements.<element>.examples"#/components/<component>/slotContentExamples/<name>"
$slotContentexamples.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):

ConventionWhat it changes
glyphswhether a component is typed glyph with a resolved name, or an ordinary element
subcomponentswhether one component becomes a parent with nested subcomponents, or stays flat
codeOnlyPropswhether a prop reaches the spec at all
namingwhether a key can be reversed back to its original layer name
stateswhether 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