Skip to content

spec(native): typed slots for Swift (text, icon, named components, content) - #8037

Merged
cixzhang merged 15 commits into
mainfrom
spec/native-swift-slots
Oct 24, 2026
Merged

cixzhang merged 15 commits into
mainfrom
spec/native-swift-slots

Conversation

@cixzhang

@cixzhang cixzhang commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Exact decision needed

How each typed slot kind appears in Swift: text, icon, and content. The kinds themselves are AST-082's (FR4, with a proposed amendment that names them); this spec only gives their SwiftUI form. This unblocks icons in buttons and badges and the start and end parts of list rows. Draft until the owner approves; nothing is built from it before then.

Existing authority searched

  • spec:AST-082 (current) FR4: free-form content is not portable; the core expresses it as a typed slot, "such as text, an icon, or a named Astryx component". FR17: shared semantic icon names, namespaced <library>:<name> names, app-registered images, no web icon substitution.
  • The contract generator implements text and content slots today; icon props of Button and Badge are web-only because no icon slot exists.
  • Open native work: the component API spec sets how parameters are spelled; this spec only adds the slot kinds.

Decision

  • S1 Text is the contract's String (localized text spellings are outside this record); icon is an IconName; content accepts any SwiftUI view, using AST-082 FR4's allowance that a platform may accept a wider form with the same meaning (as the web's React node). Text and icon take no wider form.
  • S2 IconName is a string-backed value with built-in names as static members and app-registered namespaced names; an unknown name stops a development build and draws nothing in release.
  • S3 Content slots are open @ViewBuilder closures, as in SwiftUI's Label, never AnyView, with convenience initializers for the Astryx components the core slot names.
  • S4 The owner proposes each slot's size and clips or aligns whatever it holds; an Astryx child inherits size only where core's does (an Icon in a documented icon slot, the size cascade), an explicit size wins wherever core's does, and core's AvatarGroup keeps sizing every member.
  • S5 VoiceOver reads slots in core contract order; decorative icons stay hidden.
  • S6 Every kept free-form prop declares its slot kind; the generator fails otherwise.

Rejected alternatives

None recorded in the spec.

Landing order

S1 and S3 apply AST-082 FR4 as amended by #8070 (a platform may accept a wider form for a content slot with the same meaning). This pull request lands after #8070.

Claim scope and non-goals

Per-component slot lists are set in each component's spec. Generator and Swift changes come after approval.

Evidence and implementation relationship

One file: packages/native/specs/swift/library/slots.md.

Writing rubric results

  • R1 narration: none.
  • R2 research in the record: none.
  • R3 evidence naming a change: none.
  • R4 rejected alternatives: none.
  • R5 pull request or issue references remaining: none in the record.
  • R6 ruled open questions still listing options: none; no open questions.

Scope

  • Specification only; no implementation.
  • Every changed file is under packages/native/.
  • Public text contains no internal context.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 24, 2026
@vercel

vercel Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Oct 24, 2026 8:04am UTC

Request Review

@astracat-bot

astracat-bot Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Oct 24, 2026, 8:28 AM UTC

@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

Previews ready: Storybook and Sandbox were built with this PR's docsite. CI evidence will be added when available.

View Storybook for this PR · View Sandbox for this PR

@cixzhang
cixzhang marked this pull request as ready for review October 24, 2026 03:40
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 2179207

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested: the record's direction is approved by an engineering owner, but S1 and S3 let Swift content slots take any view under an AST-082 FR4 allowance that the current FR4 does not contain, so land that FR4 amendment first (or include it here) or narrow content slots to the components the core slot names.

  • S4 should name which children take their owner's size, since core inherits size only by contract and an unsized Avatar in a web Item keeps its own md size.
  • S3 and S5 should use the core names startContent and endContent, with marker first in the reading order, instead of start and end.
  • The S1/S6 acceptance row should fail generation only for a kept free-form prop, matching S1's rule that an unslotted prop stays web-only.

[Automated review]

Comment on lines +24 to +28
- A **content** slot accepts any SwiftUI view, through a `@ViewBuilder`
closure (S3). The core's content slot holds named Astryx components; Swift
accepts this wider form under AST-082 FR4's allowance that a platform may
accept a wider form for a slot with the same meaning, as the web accepts a
React node. The component's native additions still name the Astryx

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current AST-082 FR4 has no allowance for a platform to accept a wider form for a slot: it places free-form content in the web contract and in platform contracts whose implementation runs React, and lists typed slots only as examples. Land the FR4 amendment first (or include it here) and keep this citation, or narrow content slots to the components the core slot names.

Comment on lines +42 to +48
- **S3 — Content slots are open, the SwiftUI way.** A content slot is a generic
`@ViewBuilder` closure parameter (`start: () -> Start` where
`Start: View`), as in SwiftUI's `Label { } icon: { }`, never `AnyView`. For
each Astryx component the core slot names, the view also has a convenience
initializer that takes that component's props directly (for example a row's
`start: AvatarProps`). The props initializer takes the slot as the matching
generated node type.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Item's core props are marker, startContent, label, description, and endContent. AST-082 FR3 says a platform contract never renames a core prop, so the Swift parameter here would be startContent, not start; S5's order on line 55 should also use the core names, with marker first.

Comment on lines +51 to +53
whatever view is in it. An Astryx child takes its size from its owner, as
core does (an `Icon` in a small `IconButton` is small); an explicit size on
the child wins.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Core inherits size only where a contract adopts the cascade (architecture:component-size-cascade INV2) or for an Icon in an owner's documented icon slot (component:Icon FR5); an unsized Avatar in a web Item stays md. Please name which children inherit here, and keep every other child's own default.


| Requirement | Check |
| ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| S1, S6 | The generator test fails on a fixture component whose free-form prop has no slot kind, and produces the Swift form of each kind for a fixture with all three. |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

S1 (line 33) keeps an unslotted free-form prop in the web contract, and S6 fails only a kept one; this row fails any free-form prop without a slot kind. Make it a kept prop with no kind (or a content slot that names no components), and add a fixture whose unkept prop stays web-only.

@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec c49b726

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested: an engineering owner approved this record's direction, but S1 and S3 let Swift content slots take any view under an AST-082 FR4 amendment that is not on main yet (it is open in #8070), so this record should land after that amendment or narrow content slots to the components the core slot names.

  • S2 should generate the built-in IconName members from the names AST-082 FR17 has the portable entry carry, not from core's icon registry, which is web code that FR16 keeps native from reading.
  • S1's localized-text sentence points to a component API spec that is not on main; drop it (AST-093 FR5 already fixes String) or link that record once it lands.

[Automated review]

Comment on lines +25 to +29
- A **content** slot accepts any SwiftUI view, through a `@ViewBuilder`
closure (S3). The core's content slot holds named Astryx components; Swift
accepts this wider form under the AST-082 FR4 amendment that lets a
platform accept a wider form for a slot with the same meaning, as the web
accepts a React node. The component's native additions still name the Astryx

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CURRENT AST-082 FR4 has no wider-form allowance: it places free-form content in the web contract and in platform contracts whose implementation runs React. The clause cited here exists only in open #8070. Land #8070 before this record, as the description plans, or narrow content slots to the components the core slot names.

- **S2 — Icon names are a string-backed type with the built-ins as members.**
`IconName` is a `RawRepresentable`, `ExpressibleByStringLiteral`,
`Hashable`, `Codable`, `Sendable` value. Every built-in semantic name is a
static member (`.search`, `.close`), generated from core's icon registry. A

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Core's icon registry is packages/core/src/Icon/globalIconRegistry.tsx, which maps every name to a React node (the web part, AST-082 FR18). FR16 lets native read core only through the portable entry, and FR17 has that entry carry the built-in names, so these members would come from "the built-in names the portable entry carries (AST-082 FR17)".

Comment on lines +21 to +23
- A **text** slot is a `String`, the contract's exact type (AST-093 FR5). A
localizable spelling waits on the component API spec's open question about
SwiftUI spellings.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No component API spec is on main; this question is OQ1 of open #8035. AST-093 FR5 already fixes the contract's String, so this sentence can go, or link that record by path once it lands.

@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 03df419

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested: an engineering owner approved this record's direction, but S1 and S3 let Swift content slots take any view under an AST-082 FR4 amendment that is still open in #8070, and S2 now cites an AST-082 FR16 build-time read that exists only in open #8048, which the landing order does not name.

  • Land #8070 and #8048 before this record (and add #8048 to the landing order), or narrow content slots to the components the core slot names and generate the IconName members from native's own built-in list.
  • S4's “an explicit size on any child wins” contradicts core's AvatarGroup, whose size overrides every child Avatar's size, so let that clause defer to core.

[Automated review]

Comment on lines +27 to +29
accepts this wider form under the AST-082 FR4 amendment that lets a
platform accept a wider form for a slot with the same meaning, as the web
accepts a React node. The component's native additions still name the Astryx

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current AST-082 FR4 has no wider-form clause: it keeps free-form content and render functions in the web contract and in platform contracts whose implementation runs React. The clause cited here exists only in open #8070, so land that first (as the description plans) and re-approve, or narrow content slots to the components the core slot names.

Comment on lines +37 to +39
static member (`.search`, `.close`), generated from AST-082 FR17's shared
icon names, read at build time through the icon-names read AST-082 FR16 lists
(later through core's portable entry), never from core's web icon registry. A

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current AST-082 FR16 lists no build-time read (native reads core only through a portable entry); the list that names built-in icon names is only in open #8048, which the landing order does not name. The one icon-names read native has today, readCoreIconNames in packages/native/scripts/core-docs.mjs, parses packages/core/src/Icon/globalIconRegistry.tsx. Add #8048 to the landing order and name the read meant here, or generate the members from native's own BUILTIN_ICON_NAMES.

Comment on lines +57 to +58
adopts the size cascade. Every other child keeps its own default (an unsized
`Avatar` in a list item stays `md`), and an explicit size on any child wins.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Core's AvatarGroup overrides each child Avatar's size, explicit or default (AvatarGroup.doc.mjs; Avatar.tsx resolves avatarGroup?.size ?? size), and AST-082 FR3 keeps that meaning on every platform. Let this clause defer to core: an explicit size wins wherever core's does, and a group that sizes its members keeps doing so.

@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec d61bde2

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested: an engineering owner approved this record's direction, but S1 and S3 let Swift content slots take any SwiftUI view under an AST-082 FR4 amendment that is not on main yet (it is open in #8070), and S1's localized-text pointer names a component API record that exists only in open #8035.

  • Land #8070 and #8035 first, as the description plans, then cite the FR4 clause itself rather than “its amendment” and re-approve the new head with /approve-spec, or narrow content slots to the components the core slot names.
  • S1's example on line 30 says a list item's startContent holds one of Avatar, Icon, Thumbnail, but core puts a checkbox there (CheckboxListItem, and ListItem's interactiveRef docs) and never a Thumbnail, so take the example from core.

[Automated review]

accepts this wider form under the AST-082 FR4 amendment that lets a
platform accept a wider form for a slot with the same meaning, as the web
accepts a React node. The component's native additions still name the Astryx
components the core slot holds, and whether it holds one or many (a list item's `startContent` holds one of `Avatar`, `Icon`, `Thumbnail`; a card holds many).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Core puts a checkbox in this slot (CheckboxListItem renders one as Item's startContent, and ListItem's interactiveRef docs name “a checkbox in startContent”), and component:Item lists start content as “a status dot, a radio or checkbox, an icon, a short timestamp”; no core doc, story or source puts a Thumbnail here. Take the example from core (an Icon, an Avatar, or a checkbox), or leave the list to each component's spec.

@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec a73df5c

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested: an engineering owner approved this record's direction, but S1 and S3 still let Swift content slots take any SwiftUI view under an AST-082 FR4 clause that is not on main yet (it is proposed in #8070). Land #8070 first and re-approve this record on its new head, or narrow content slots to the components the core slot names.

  • S1 says a localized text spelling is outside this record (lines 22–23) but then rules out localized text (line 31); keep one of the two.

[Automated review]

wider form for a content slot with the same meaning, as the web
accepts a React node. The component's native additions still name the Astryx
components the core slot holds, and whether it holds one or many (a list item's `startContent` holds one of `Icon`, `Avatar`, or `CheckboxInput`; a card holds many).
Text and icon slots take no wider form (no attributed or localized text, no

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 22–23 say a localized text spelling is outside this record, but this line rules localized text out for text slots. Keep one: drop “or localized” here (“no attributed text, no image”), or drop the sentence on lines 22–23.

@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec a790b21

@cixzhang
cixzhang force-pushed the spec/native-swift-slots branch from a790b21 to 91a6995 Compare October 24, 2026 07:56
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 91a6995

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good: S1–S6 now rest on AST-082 FR4, FR16 and FR17 as they stand on main, an engineering owner approved this exact head, and the earlier requested changes are addressed. Two optional wording tweaks are left inline: say which initializer S3's last sentence means, and name the macOS floor beside iOS in the S2 check.

[Automated review]

Comment on lines +51 to +52
`startContent: AvatarProps`). The props initializer takes the slot as the matching
generated node type.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: this sentence follows the AvatarProps convenience initializer, so it reads as giving that same initializer a node type, while the S3 check (line 77) has it take AvatarProps. If it means the initializer that takes the view's generated props, naming it would remove the ambiguity, for example: “The initializer that takes the view's generated props takes the slot as the matching generated node type.”

| Requirement | Check |
| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| S1, S6 | The generator test fails on a fixture component that keeps a free-form prop with no slot kind, or keeps a content slot that names no components; a fixture's unkept free-form prop stays web-only with no Swift form; a fixture with all three kinds produces each Swift form. |
| S2 | Every built-in name maps to an SF Symbol that exists on the package's iOS floor; registering `acme:rocket` makes `"acme:rocket"` draw it; an unregistered name stops a development build and draws nothing in release. |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: the Swift package also declares macOS 14 (packages/native/apple/Package.swift), and AST-082 FR17 checks icon map coverage per native platform, so “exists on the package's iOS and macOS floors” would cover both platforms this record serves.

@cixzhang
cixzhang merged commit 15ee091 into main Oct 24, 2026
69 checks passed
@github-actions
github-actions Bot deleted the spec/native-swift-slots branch October 25, 2026 06:20

This branch was successfully deployed

1 active deployment
Preview — 91a6995a Deployed Oct 24, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant