EnumProp
Enum property definition for a prop whose value is one of a fixed list, read from a Figma variant property. The admitted values are carried in its own enum member rather than by the schema, because they come from the library. A prop of type: string without an enum is a StringProp.
Path
component-api:props.<prop>
Members
| Member | Type | Required | Description |
|---|---|---|---|
type | 'string' | Yes | The discriminator — always 'string'. |
default | string | Yes | The value a consumer gets without setting the prop — one of enum’s entries. |
enum | string[] | Yes | The closed list of accepted values, in authored order — it is the variant axis, and the render direction rebuilds the component set from it positionally. |
nullable | boolean | No | Whether this prop accepts a null value. |
$extensions | PropExtensions | No | Platform provenance under reverse-domain keys. |
Example
type: stringdefault: primaryenum: [primary, secondary]States
An enum prop named by a specs.states entry participates in state classification exactly as a boolean does — see the statesToContract rule. An enum whose entries are all state values can leave the emitted contract entirely when every concept naming it is browser-managed.
Platform bindings
Figma
Disposition: bound · Realised by: VARIANT property options / ComponentSet variant axes
Rules: variantAxes — with boolean, number
The option list is the variant axis, authored order preserved — the render direction rebuilds the component set from it positionally. nullable: false is recorded: the enum lists every accepted value.
CSS
Disposition: bound · Realised by: Css, enumCase
Rules: propsToSelectors — with boolean, number, object
An enum prop’s values become attribute selectors, lowercased by the enumCase contract — HTML attribute selectors are case-sensitive, and the emitting platform writes the same normalized spelling. An enum classified as a state concept selects by the concept’s selector instead.
React
Disposition: bound · Realised by: a named union type, one member per enum value
Rules: statesToContract — with boolean
The union is named for the component and prop; values are lowercased by the enumCase contract, and the declared default is normalized with them. The scaffold writes the current value as a data-<prop> attribute on the component’s root, which is the selector surface the CSS binding’s propsToSelectors rule states.
Web Components
Disposition: bound · Realised by: a named union type, reflected as an attribute the stylesheet selects on
Rules: statesToContract — with boolean
Values are lowercased by the enumCase contract. The element reflects the prop so the stylesheet can select :host([<attr>="<value>"]); the attribute spelling comes from the one shared function the emitter and the stylesheet both call, so the two cannot disagree. Reserved global names (hidden, title, id, every aria-*) fall back to data-<attr>.
Decisions
- ADR-015 — Resolve
AnyProponeOfschema violation betweenTextPropandIconProp - ADR-019 — Allow null in StringProp.default
- ADR-105 — Type–Schema Parity for Overlapping Prop Unions
- ADR-125 — Instance-example orientation
Rules
| Rule | Statement |
|---|---|
| DSPEC-12 | null is meaningful only under a nullable prop |
Source
| Format | File |
|---|---|
| JSON Schema | packages/schema/schema/component.schema.json |
| TypeScript | packages/schema/types/Props.ts |
| Specification | §4.2, §11 |