Skip to content

Closed Style Value Sets

Summary
Five Styles keys that inherited an open string wrapper by accident become named closed value sets, each dropping three value forms nothing writes.
Status
ACCEPTED · 2026-11-01
Deciders
Nathan Curtis (author)

Context

Five Styles properties have a closed, known set of values and declare none of them. Each is typed Style, and each points at a generic string wrapper in the schema:

PropertyValues it accepts in practiceTyped asSchema $ref
strokeAlignINSIDE, OUTSIDE, CENTERStyleMixedStringStyleValue
layoutSizingHorizontalFIXED, HUG, FILLStyleStringStyleValue
layoutSizingVerticalFIXED, HUG, FILLStyleStringStyleValue
textAlignVerticalTOP, CENTER, BOTTOMStyleStringStyleValue
primaryAxisSizingModeAUTO, FIXEDStyleStringStyleValue

Both wrappers are open, and Style is the widest value type the package has:

# types/Styles.ts — current
Style: string | boolean | number | null | TokenReference | PropBinding | Conditional
# schema/styles.schema.json — current
StringStyleValue:
oneOf: [ { type: string }, { $ref: TokenReference }, { type: null } ]
MixedStringStyleValue:
oneOf: [ { type: string }, { $ref: TokenReference }, { type: null } ]

So each of the five admits any string whatsoever, plus a token reference — and in TypeScript, additionally a prop binding and a conditional.

Nothing decided that. The five inherited a convenience wrapper, and the constitution’s typing rule says the opposite should hold: “When a Styles property has a closed, known set of values and is not token-bindable … it MUST be typed as a named type rather than Style.” Eleven sibling properties already do — Position, LayoutMode, MainAxisAlignment, CrossAxisAlignment, WrapAlignment, TextAlignHorizontal and TextOverflow among them. These five are the remainder.

The cost falls on anyone implementing against the contract. The admitted values for these five appear nowhere in this package — not in types/, not in schema/. A reference page for strokeAlign can only say string, and a platform author has nothing to implement against.

The openness is also unused. Across every spec document available for inspection, 10,547 values are carried by these five properties, and every one is a plain string from the sets above or null. None is a token reference, prop binding or conditional.


Decision Drivers

  • A platform must be able to read the admitted values from the contract. This is the premise of the schema enrichment work; these five are the clearest remaining case where the contract withholds them.
  • The constitution already resolves the typing question. A closed, non-token-bindable set is a named type (constitution, Additional Constraints). The five are an existing inconsistency rather than an open choice.
  • Type and schema must stay in sync. Narrowing one without the other is drift, which constitution I forbids.
  • A contract that admits what nothing writes cannot reject what is wrong. strokeAlign: "INNER" validates today.
  • Narrowing a published field type is breaking and must be recorded as such (constitution III), whatever its practical reach.

Options Considered

(Pre-decided — no alternatives evaluated.)

The author directed the narrowing and accepted the MAJOR change class when the openness was surfaced during the pattern and constraint work tracked in issue #819. This ADR records that decision; it does not re-open it.


Decision

Declare each set, and drop the value forms nothing writes.

Type changes (types/)

FileChangeBump
Styles.tsAdd type StrokeAlignMINOR
Styles.tsAdd type LayoutSizingMINOR
Styles.tsAdd type TextAlignVerticalMINOR
Styles.tsAdd type PrimaryAxisSizingModeMINOR
Styles.tsRetype field strokeAlign from Style to StrokeAlign | nullMAJOR
Styles.tsRetype fields layoutSizingHorizontal, layoutSizingVertical from Style to LayoutSizing | nullMAJOR
Styles.tsRetype field textAlignVertical from Style to TextAlignVertical | nullMAJOR
Styles.tsRetype field primaryAxisSizingMode from Style to PrimaryAxisSizingMode | nullMAJOR
Styles.tsRetype field TextContentStyles.textAlignVertical from Style to TextAlignVertical | nullMAJOR
index.tsExport StrokeAlign, LayoutSizing, TextAlignVertical, PrimaryAxisSizingModeMINOR

Example — new shape (types/Styles.ts):

# Before
Styles:
strokeAlign: Style # string | boolean | number | null
# | TokenReference | PropBinding | Conditional
layoutSizingHorizontal: Style
primaryAxisSizingMode: Style
# After
StrokeAlign: "'INSIDE' | 'OUTSIDE' | 'CENTER'"
LayoutSizing: "'FIXED' | 'HUG' | 'FILL'"
PrimaryAxisSizingMode: "'AUTO' | 'FIXED'"
Styles:
strokeAlign: StrokeAlign | null # MAJOR — three value forms removed
layoutSizingHorizontal: LayoutSizing | null
primaryAxisSizingMode: PrimaryAxisSizingMode | null

Schema changes (schema/)

FileChangeBump
styles.schema.jsonAdd definition StrokeAlignStyleValueMINOR
styles.schema.jsonAdd definition LayoutSizingStyleValueMINOR
styles.schema.jsonAdd definition TextAlignVerticalStyleValueMINOR
styles.schema.jsonAdd definition PrimaryAxisSizingModeStyleValueMINOR
styles.schema.jsonRepoint Styles.strokeAlign from MixedStringStyleValue to StrokeAlignStyleValueMAJOR
styles.schema.jsonRepoint Styles.layoutSizingHorizontal, Styles.layoutSizingVertical from StringStyleValue to LayoutSizingStyleValueMAJOR
styles.schema.jsonRepoint Styles.textAlignVertical and TextContentStyles.textAlignVertical from StringStyleValue to TextAlignVerticalStyleValueMAJOR
styles.schema.jsonRepoint Styles.primaryAxisSizingMode from StringStyleValue to PrimaryAxisSizingModeStyleValueMAJOR

Example — new shape (schema/styles.schema.json):

# New definition under #/definitions
StrokeAlignStyleValue:
description: "Stroke alignment value. Structural property — not token-bindable."
oneOf:
- const: INSIDE
description: "The stroke is drawn within the element's bounds."
- const: OUTSIDE
description: "The stroke is drawn beyond the element's bounds."
- const: CENTER
description: "The stroke straddles the boundary."
- type: "null"
title: "No stroke"
description: "The element has no visible stroke for an alignment to apply to."
# Styles.strokeAlign now references it
strokeAlign:
$ref: "#/definitions/StrokeAlignStyleValue"

Notes

Each set is declared as oneOf branches of const with a per-option description, per ADR-114, rather than a bare enum.

layoutSizingHorizontal and layoutSizingVertical share LayoutSizingStyleValue: the same set, named once.

null is retained on all five. It is in the current contract, it is the null-unset convention, and the inspected documents carry it 229 times across strokeAlign and the two sizing properties. Dropping it would be a second narrowing with nothing to justify it.

TextContentStyles.textAlignVertical moves with its Styles counterpart, because every content-styles member is typed identically to the Styles member it mirrors.


Type ↔ Schema Impact

  • Symmetric: Yes.
  • Parity check: each new string literal union has exactly one new schema definition, and each retyped field has exactly one repointed $ref.
TypeSchema definitionFields
StrokeAlignStrokeAlignStyleValueStyles.strokeAlign
LayoutSizingLayoutSizingStyleValueStyles.layoutSizingHorizontal, Styles.layoutSizingVertical
TextAlignVerticalTextAlignVerticalStyleValueStyles.textAlignVertical, TextContentStyles.textAlignVertical
PrimaryAxisSizingModePrimaryAxisSizingModeStyleValueStyles.primaryAxisSizingMode

The four new definitions each carry a named type, satisfying constitution I in both directions.


Downstream Impact

No consumer writes or reads a token reference, prop binding or conditional on any of the five properties, so none has usage to change. Each needs only to recompile against the narrowed types.

ConsumerImpactHighlights
specs-schemaThis ADRFour types added, five fields narrowed
specs-from-figmaRecompileWrites a plain string or null for each of the five; the narrowed types admit exactly that
figma-from-specsRecompileReads the five as strings; the declared sets match the values it already handles
from-specsRecompileNo usage of the removed value forms
react-from-specsRecompileNo usage of the removed value forms
webcomponents-from-specsRecompileNo usage of the removed value forms
specs-cliRecompileNo usage of the removed value forms
specs-plugin-2RecompileCompiles the capture source, which writes a plain string or null

A third party assigning a TokenReference, PropBinding or Conditional to one of the five would no longer compile. No such consumer exists in this workspace, and the CHANGELOG entry must say so rather than leaving a reader to judge whether their usage was real.


Semver Decision

Target version: 0.40.0 — the version of the active release branch this ADR merges into.

Change class: MAJOR — for CHANGELOG placement, not a version bump.

Justification: five exported fields narrow, each dropping three admitted value forms. Constitution III: “Removing or renaming an exported type or a named field within a type is a breaking change and MUST follow semantic versioning.” The four added types and four added schema definitions are MINOR-class on their own; the field retyping governs.


Consequences

  • The admitted values for all five properties become readable from the types and the schema, instead of only from a transform’s source.
  • The constitution’s structural-enum rule holds across every closed Styles value set, rather than eleven of sixteen.
  • A wrong value is rejected: strokeAlign: "INNER" validates today and will not after this.
  • Each reference page gains an option table in place of a bare string.
  • Five published field types narrow. No consumer is affected, but the contract has changed and the CHANGELOG must record it under ### Breaking.
  • A future token-bound value on any of the five requires a schema change to re-admit. That capability was never intended, so closing it is deliberate — but it is no longer free.