Skip to content

spec(native): Astryx looks as SwiftUI styles, with views built on them - #8091

Merged
cixzhang merged 2 commits into
mainfrom
spec/native-swift-styles
Oct 24, 2026
Merged

cixzhang merged 2 commits into
mainfrom
spec/native-swift-styles

Conversation

@cixzhang

@cixzhang cixzhang commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Exact decision needed

Astryx ships its look as SwiftUI styles: look-only conformances to SwiftUI's style protocols, reached as .astryx with only a component's core visual props, and Astryx's own views are built on them. The owner chose this direction; the record states it.

Existing authority searched

  • spec:AST-093 FR2 (native-first: components sit on the platform's own control).
  • The Swift component API spec (packages/native/specs/swift/library/component-api.md): names, the contract as parameter list, and no styling parameters beyond the contract. This record adds styles beside the views without changing that spec.
  • The Swift theme environment spec: stock controls take the theme's tint and text colors.

Decision

  • Y1 For each component whose core contract matches a SwiftUI control whose style protocol accepts a custom conformance, Astryx ships a conformance to that control's style protocol, reached as .astryx with only the core visual props; each style reads the theme; the view is the control plus that style plus behavior props; Astryx declares no style protocol of its own.
  • Y2 Styles are look-only: core visual props only; behavior props stay on the view.
  • Y3 Each style names its member and components: ButtonStyle .astryx(variant:size:elevation:) for Button/IconButton and SwiftUI's own Link, NavigationLink, ShareLink; ToggleStyle .astryxSwitch (Switch) and .astryxCheckbox on macOS (CheckboxInput); ProgressViewStyle .astryxProgressBar and .astryxSpinner; LabelStyle for the icon-and-label layout of Button and Badge; MenuStyle for the DropdownMenu trigger; GroupBoxStyle for Card; LabeledContentStyle for Field; ControlGroupStyle for ButtonGroup. PickerStyle and TextFieldStyle accept no custom conformance, so Selector and TextInput use system styles with the theme's tint.
  • Y4 Style types are Astryx<Control>Style, since the unprefixed name is SwiftUI's protocol; callers write .astryx.
  • Y5 Accessibility comes from the system control; ToggleStyle is the exception, so the Astryx toggle styles keep the toggle trait and value and act on a tap or the default action.

Rejected alternatives

None recorded in the spec.

Also in this pull request

One line in theme-environment.md E2: the theme values with no SwiftUI equivalent (radius, spacing, heights, borders, backgrounds) are read by Astryx components and Astryx's SwiftUI styles.

Claim scope and non-goals

No change to the component API spec. Which style parameters exist follows each component's generated contract.

Landing order

Builds on the component API spec (#8035) and reads the theme as the theme environment spec (#8040) says; lands after both.

Evidence and implementation relationship

One file: packages/native/specs/swift/library/styles.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; Open questions reads None.

Scope

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

@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 11:47am 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, 12:09 PM UTC

@cixzhang
cixzhang marked this pull request as ready for review October 24, 2026 04:59
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec cfc164b

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

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR

🧪 Sandbox Preview

View Sandbox for this PR

No new or modified components detected.

Bundle Size Summary

No component packages changed.

Accessibility Audit

Status: No accessibility violations detected.

Visual Regression

46 of 494 shot(s) changed.

A change here is a question, not a failure: check whether the after is the
picture you intended. Record that review on the PR. Baseline maintenance is an
explicit dispatch of CI; this report never rewrites the baseline or adds a release gate.

component story theme mode pixels
Selector Indicator Space Bottom Sheet Narrow End RTL neutral light 753,933
Selector Indicator Space Bottom Sheet Wide Start neutral light 740,072
Chat Full AI Chat probe light 230,823
Chat Full AI Chat probe dark 229,805
RichTextEditor Markdown parity: side by side probe dark 94,866
RichTextEditor Markdown parity: side by side probe light 89,762
Collapsible Dividers probe dark 66,445
Collapsible Dividers probe light 66,445
Chat Default neutral dark 36,304
Chat Default neutral light 35,767
Chat Empty State probe light 23,531
Chat Empty State probe dark 22,622
ChatAutoScroll Scroll Behavior Comparison neutral dark 15,378
ChatAutoScroll Scroll Behavior Comparison neutral light 14,107
Chat With Attachments probe light 13,406
Chat With Attachments probe dark 11,232
ProgressBar With Target Mark probe dark 7,895
ProgressBar With Target Mark probe light 7,895
Markdown Default neutral dark 7,573
Markdown Default neutral light 7,566

and 26 more.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

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

Requesting changes on two small points in the Swift styles spec; the direction itself is owner-approved on this head.

  • The Relation line extends packages/native/specs/swift/library/component-api.md, which is not in this branch or on main yet (it arrives with #8035), and Y1 and Y3 also rely on the theme environment from #8040 without naming it: land after both or stack on them, and name the theme environment record in the Relation line.
  • Y1 and Y3's last sentence would require styles for Picker and TextField, which Y3 excludes because PickerStyle and TextFieldStyle take no custom conformance: scope both to controls whose style protocol accepts a custom conformance.

Because approval is tied to the exact head, a fixed head needs a fresh /approve-spec <full head SHA> from an engineering owner.

[Automated review]

# SwiftUI styles (Swift)

- Status: draft
- Relation: extends `packages/native/specs/swift/library/component-api.md`

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.

component-api.md is not in this branch or on main yet (it arrives with #8035), and Y1 and Y3 also read the theme environment from #8040, which this line does not name. Land after both (or stack on them) and add theme-environment.md here.

Comment on lines +44 to +46
tint and text colors from the theme environment. A component added later
joins this table when its core contract matches a SwiftUI control with a
public style protocol.

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.

PickerStyle and TextFieldStyle are public protocols, so this rule, and Y1's scope at lines 19-21, would admit the Selector and TextInput styles that lines 42-43 rule out. Suggested wording: "...matches a SwiftUI control whose style protocol accepts a custom conformance."

@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 86c2e77

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

Requesting changes on one remaining point; the direction is owner-approved, and the earlier scope fix (only style protocols that accept a custom conformance) is in. The Relation line extends component-api.md and reads the theme through theme-environment.md, but neither file is on main yet (they arrive with #8035 and #8040), so merging this now would leave the record's basis, and the theme environment Y1 and Y3 rely on, pointing at files that do not exist. Once both land, rebase onto them (or stack this branch on #8040) and post a fresh /approve-spec <full head SHA> for the new head, which you can do as an engineering owner. Two non-blocking gaps are worth settling in the same pass: which visual props .astryx takes where one protocol serves two components (ProgressBar and Spinner; Switch and CheckboxInput), and which components the LabelStyle, LabeledContentStyle and ControlGroupStyle rows style.

[Automated review]

Comment on lines +4 to +7
- Relation: extends `packages/native/specs/swift/library/component-api.md`,
reads the theme as `packages/native/specs/swift/library/theme-environment.md`
says, and applies AST-093 FR2 (native-first: a component sits on the platform's
own control). It decides how Astryx's look reaches SwiftUI's own controls.

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.

component-api.md and theme-environment.md are not in this branch or on main yet: they arrive with #8035 and #8040, and #8040 itself lands after #8031, #8038 and #8035. Y1, Y3 and the Y1 capture check rest on them, so merging this head first would leave both paths pointing at nothing. Once they land, rebase onto them (or stack this branch on #8040) and post a fresh /approve-spec <full head SHA>.

@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 5a7e08e

@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 876fee3

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

Requesting changes on one remaining point: the direction is owner-approved on this head, but the Relation line (styles.md:4-6) still extends component-api.md and reads the theme through theme-environment.md, and neither file is on main yet (they arrive with #8035 and #8040), so merging this first would leave the record's basis, and the theme environment Y3 relies on, pointing at files that do not exist. Once both land, rebase onto them and post a fresh /approve-spec <full head SHA> for the new head, which you can do as an engineering owner. Worth settling in the same pass:

  • Which input picks the checkbox or spinner look where one protocol serves two components (ToggleStyle, ProgressViewStyle), and which components the LabelStyle, LabeledContentStyle and ControlGroupStyle entries style.
  • Y5's "a style draws only" does not hold for ToggleStyle, since a custom toggle style has to flip the on state itself.
  • The Link, NavigationLink and ShareLink compile check passes for any view, so only a capture shows they take the Astryx look.

[Automated review]

Comment on lines +36 to +37
| `ToggleStyle` | Switch; CheckboxInput on macOS |
| `ProgressViewStyle` | ProgressBar, Spinner |

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.

ToggleStyle and ProgressViewStyle each carry two looks (Switch and macOS CheckboxInput; ProgressBar and Spinner), but Y4 gives each protocol one type behind .astryx and Y2 allows only core visual props, none of which picks the look. Name the input that chooses the checkbox or the spinner, or give each look its own member.

Comment on lines +52 to +53
- **Y5 — Accessibility comes from the system control.** A style draws only;
the control keeps its name, traits, actions, and focus. A stock control

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.

"A style draws only" does not hold for ToggleStyle: SwiftUI leaves a custom toggle style to flip configuration.isOn itself. Say whether the Astryx toggle style composes the system switch (keeping AST-082 FR11's switches on the platform control) or draws and drives its own.


| Requirement | Check |
| ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Y1 | A compile test applies every Y3 style to its SwiftUI control through `.astryx`; `Link`, `NavigationLink`, and `ShareLink` accept `.buttonStyle(.astryx(…))`; a source check finds no public protocol declared by Astryx whose name ends in `Style`. |

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.

.buttonStyle(_:) is a modifier on every View, so this compile check passes whatever Link, NavigationLink and ShareLink draw; a capture like the Button one on the next row would show they take the Astryx look.

@cixzhang
cixzhang force-pushed the spec/native-swift-styles branch from 876fee3 to a419530 Compare October 24, 2026 10:59
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec a419530

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

Requesting changes on one point: the direction is owner-approved on this head and the records the Relation names are now on main, but the LabelStyle row gives DropdownMenu items Astryx's label layout (styles.md:39) while the MenuStyle row keeps the menu's contents system (:40), and a SwiftUI menu presents its items with the system layout, so a DropdownMenu built from this record cannot satisfy both. Dropping "and DropdownMenu items" from the LabelStyle row, or saying the items keep the system layout, fixes it; the new head then needs a fresh /approve-spec <full head SHA>, which you can post as an engineering owner. Smaller points worth settling in the same pass:

  • Y1's ".astryx<Component> where one protocol styles more than one component" does not match the single .astryx for ButtonStyle and LabelStyle or the .astryxCheckbox name.
  • theme-environment.md E2 still says corner radius, spacing, element heights, borders and backgrounds are read only by Astryx components, which the styles now also read.
  • The Y1 capture check's bare Link names Astryx's own view in a file that imports only Astryx; SwiftUI.Link is meant.

[Automated review]

Comment on lines +39 to +40
| `LabelStyle` | `.astryx` | the icon-and-label layout of Button, Badge, and DropdownMenu items |
| `MenuStyle` | `.astryx` | DropdownMenu trigger (menu contents stay system) |

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.

These two rows conflict for DropdownMenu items: the LabelStyle row gives them Astryx's icon-and-label layout, while the MenuStyle row keeps the menu's contents system, and a SwiftUI Menu presents its items in the system menu, which does not draw a custom LabelStyle. Dropping "and DropdownMenu items" from the LabelStyle row, or saying the items keep the system layout, resolves it.

Comment on lines +22 to +23
conformance, Astryx ships a conformance to that control's style protocol, reached as `.astryx` (or `.astryx<Component>` where one protocol styles
more than one component, Y3) with only the component's core visual props as

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: Y3 gives ButtonStyle (Button, IconButton) and LabelStyle (three components) a single .astryx each, and names CheckboxInput's member .astryxCheckbox, so "where one protocol styles more than one component" does not match the table; "where one protocol carries more than one look" would.

| Requirement | Check |
| ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Y1 | A compile test applies every Y3 style to its SwiftUI control through its Y3 member; a source check finds no public protocol declared by Astryx whose name ends in `Style`. |
| Y1 | A capture test draws `SwiftUI.Button("x") {}.buttonStyle(.astryx(variant: .primary))` and `Button("x", variant: .primary) {}` identically in two themes, light and dark. `Link`, `NavigationLink`, and `ShareLink` with `.buttonStyle(.astryx(variant: .primary))` draw the same look. |

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: in a test file that imports only Astryx, a bare Link names Astryx's own view (component-api.md A1a and A1b), so SwiftUI.Link says which one this check means.

@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec baf628c

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

This looks ready to approve: the Swift styles record is owner-approved on this head, contradicts nothing in AST-082 or AST-093, and its LabelStyle and MenuStyle rows no longer overlap. Two points are worth a follow-up, neither blocking:

  • Y1's member rule says a protocol that styles one component reaches it as .astryx, but ButtonStyle (Button, IconButton) and LabelStyle (Button, Badge) each serve two and CheckboxInput's member is .astryxCheckbox, so "a protocol with one Astryx look" would match the table.
  • The record leaves open which props count as core visual props, what LabelStyle's .astryx takes, what CheckboxInput draws on iOS, and whether ToggleButton, Collapsible and Link join the Y3 table.

Any further commit needs a fresh /approve-spec <full head SHA> from an engineering owner, which you can post yourself as one.

[Automated review]

Comment on lines +22 to +26
conformance, Astryx ships a conformance to that control's style protocol, with only the component's core visual props as parameters. A protocol that
styles one component reaches it as `.astryx` (`ButtonStyle`, `LabelStyle`,
`MenuStyle`, `GroupBoxStyle`, `LabeledContentStyle`, `ControlGroupStyle`);
one that styles several reaches each as `.astryx<Component>` (`.astryxSwitch`,
`.astryxCheckbox`, `.astryxProgressBar`, `.astryxSpinner`). Each style reads the theme from the

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 rule says a protocol that styles one component reaches it as .astryx, but ButtonStyle serves Button and IconButton (line 38), LabelStyle serves Button and Badge (line 41), and CheckboxInput's member is .astryxCheckbox rather than .astryxCheckboxInput. "A protocol with one Astryx look reaches it as .astryx; one with several reaches each look as .astryx<Look>" would match every member in Y3.

| `ButtonStyle` | `.astryx(variant:size:elevation:)` | Button, IconButton; also SwiftUI's own `Link`, `NavigationLink`, and `ShareLink`, which SwiftUI styles with `ButtonStyle` |
| `ToggleStyle` | `.astryxSwitch`; `.astryxCheckbox` on macOS | Switch; CheckboxInput |
| `ProgressViewStyle` | `.astryxProgressBar`; `.astryxSpinner` | ProgressBar (determinate or not); Spinner |
| `LabelStyle` | `.astryx` | the icon-and-label layout of Button and Badge |

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: Y2 gives a style the component's core visual props with the generated types, but this row serves Button (ButtonVariant, ButtonSize, ButtonElevation) and Badge (BadgeVariant only), so the parameters of this .astryx are undefined; naming them, or saying this style takes none, closes the gap.

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

This branch was successfully deployed

1 active deployment
Preview — baf628cc 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