Skip to content

Adoption feedback: migrating a real Next.js 16 app to Astryx (0.1.8) — 10 findings + suggestions #4276

Open

Description

@ejc3

Adoption feedback: migrating a real Next.js 16 app to Astryx (0.1.8)

We migrated a production dark-only chat/transcript viewer onto @astryxdesign/[email protected] — Next.js 16 App Router, React 19, webpack build, pnpm 10 (strict node_modules), a strict CSP (style-src 'self' 'unsafe-inline', font-src 'self', connect-src 'self'), and ~130 Playwright locators against our own CSS classes. Overall it went well, and a few things were genuinely excellent — so first, credit where it's due, then the actionable findings.

Happy to split any of these into individual tracked issues if you'd prefer; consolidating so triage is one read.

What worked really well

  • BaseProps forwards className / style / data-* / aria-*. This is what made an incremental migration of an app with ~130 CSS-selector tests possible at all — we could swap components without rewriting the test suite in the same commit. Arguably the single most important adoption property; worth advertising louder.
  • The CLI is a better docs surface than the website. astryx docs <topic> / component <Name> / hook / template, plus --json and --dense, gave complete, offline, machine-readable docs. We initially tried scraping the docs site (Next RSC payload, fetches poorly) and threw it away once we found the CLI.
  • astryx docs migration predicted our worst bug before we hit it — the "Cascade Layer Safety" section names the exact webpack @import-hoisting failure and the layers.css remedy. Docs that name the specific silent failure of a specific bundler are rare.
  • Pre-compiled CSS is genuinely build-step-free on Next+webpack, and CSP-clean (no @font-face, no remote url() in reset.css/astryx.css/the built theme).
  • TextArea's iOS auto-zoom guard (@media (pointer: coarse) { font-size: max(1rem, …) }) is pointer-aware — better than the unconditional 16px we had.

Bugs / friction (roughly by cost)

1. @stylexjs/stylex is missing from the documented install line — hard runtime failure on pnpm.
README Quick Start and astryx docs getting-started both say npm install @astryxdesign/core @astryxdesign/theme-neutral. But @stylexjs/stylex is a peer dependency of core, and 202 of dist/'s files import it at runtime:

$ grep -rl "@stylexjs/stylex" node_modules/@astryxdesign/core/dist --include="*.js" | wc -l
202

npm/yarn auto-install peers, so it's invisible there. pnpm does not — under strict node_modules every component throws on import. Suggest adding it to the documented install line, or moving it to dependencies (consumers who don't author StyleX have no reason to pin its version). An astryx doctor check would also catch it.

2. astryx theme build's default output location is a trap for a .ts theme source.
The default writes <name>.{css,js,d.ts,variants.d.ts} next to the source, so remote-claw.js lands beside remote-claw.ts. With next.config's experimental.extensionAlias: { ".js": [".ts", …] } (which many TS monorepos set), import "./theme/remote-claw.js" then silently resolves to the source theme (runtime <style> injection) instead of the built one — same export name, same shape, just without __built: true. --out fixes it and relocates the whole set (all four artifacts follow the CSS path's dirname), which we only discovered by reading the CLI source. astryx theme build --help describes -o, --out as "Output CSS file path", which reads as CSS-only. Suggest: "output directory for all theme artifacts (named by the CSS path)", plus a note in astryx docs theme that the default co-locates a .js beside a .ts source.

3. Generated artifacts carry a Generated: <ISO timestamp> header, so committed output can't be drift-checked.
We commit the built theme so CI/Vercel never run the CLI. The timestamp makes every rebuild a diff, defeating a "did someone edit the built file instead of the source?" gate; we post-process the line away for byte-identical rebuilds. Source:/Command: already carry the useful provenance — suggest dropping the timestamp or gating it behind a flag (SOURCE_DATE_EPOCH / --no-timestamp). Reproducible generated output is worth a lot.

4. The astryx init nudge prints on stdout of every command.
astryx docs theme | head -2 begins with Next step: run 'pnpm exec astryx init' …. It's prepended to docs/component/hook/template stdout, so anything that pipes/captures has to strip it. --json is clean (right instinct) — suggest sending the nudge to stderr so it stays visible to a human but disappears from pipes.

5. Minor: astryx docs --list errors with unknown option '--list', even though bare astryx docs prints exactly that list and component --list / template --list both exist.


Theming / behavior

6. defineTheme's accent scale inverts the accent in dark mode — with no warning at the place you'd look.
Seeding the family the documented way, color: { accent: '#5457e8' }, generates:

--color-accent:    light-dark(#424BDA, #CBBEFF)
--color-on-accent: light-dark(#FFFFFF, #001F9C)

i.e. in dark mode the accent becomes a pale surface carrying dark text. Coherent as a system default, but a surprise when the reason you're writing a theme is to carry a fixed brand across — our primary button silently became pale lavender with dark-blue text (measured, not eyeballed; our full test suite stayed green because our design guard asserted the disabled treatment, not the hue). The fix is supported — pin both halves — but astryx docs theme only warns against hand-writing --color-accent alone, which nudges you toward the scale API and away from the thing you actually need. Suggest documenting that the seed inverts for dark mode, with the pin-both-halves snippet as the supported way to keep a fixed brand fill.

7. Focus rings come from --color-accent, which fights a pinned brand fill — and there's no focus token.
astryx.css draws focus as outline: 2px solid var(--color-accent). A theme whose accent is a dark, saturated fill (correct for white-on-accent buttons) therefore gets a dark, low-contrast ring on a dark background (~3.4:1 vs the 5.8:1 our text-accent would give). It still clears WCAG 2.2 SC 1.4.11's 3:1, so nothing is broken — just dimmer than intended, and invisible until you tab through on a dark theme. Suggest a dedicated --color-focus-ring defaulting to --color-accent, so a dark theme with a saturated brand can set fill and ring independently.

8. <Text size> is silently inert whenever the theme styles that type.
size is documented as an override, but on a themed app it does nothing for any type the theme emits a rule for:

<Text type="supporting" size="xsm">…</Text>
// class="astryx-text supporting xsm …", computed font-size: 12px  ← size had no effect

It's cascade layers, not specificity: @layer astryx-theme { .astryx-text.supporting { font-size: … } } beats the xsm size class in @layer astryx-base every time, and the xsm class is still on the element so it looks like it worked. We only caught it measuring getComputedStyle. Suggest emitting the size classes into astryx-theme too (or a later layer), or having size set a custom property the theme rule reads — or documenting that size and a themed type don't compose.


Component-fit gaps (where we couldn't adopt, and kept our own)

9. ChatComposerInput can't host a composer with platform-specific Enter behavior.
It's a contentEditable div whose key handler is unconditional:

if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); … onSubmit?.(text); }

Our composer sends on Enter on a desktop but inserts a newline on a touch keyboard (a soft-keyboard Return mustn't strand a multi-line prompt), and guards IME composition. ChatComposerInput would send on Enter on a phone, with no prop to override it — and adopting it means trading a controlled-value + auto-grow <textarea> for contentEditable + serialize(), plus its built-in history/trigger model. A contentEditable input with mentions is a reasonable default; it just isn't a host for bespoke platform behavior, and there's no seam. Suggest an onKeyDown / shouldSubmitOnEnter hook, or letting ChatComposer accept a plain controlled <textarea> in its input slot without the contentEditable assumptions (today the shell's click-to-focus/submit wiring assume the default input). We migrated the composer's controls (Send/Mode/attach → Button/IconButton) cleanly and kept only the input.

10. Button has a destructive variant but no constructive/success counterpart.
ButtonVariantMap is primary | secondary | ghost | destructive — a red destructive with no green mirror. Migrating a permission grant/deny (approve = green, reject = red — a deliberate security-UX signal), we had destructive for Deny but nothing for Allow. primary recolors it to the brand and reads as "the main action" rather than "the affirmative/safe one", so we kept a small semantic tint over a secondary Button. Suggest a constructive (or success) variant mirroring destructive, drawing from the --color-success family the theme already defines — approve/reject, accept/decline, confirm/cancel are common enough that having one side but not the other pushes every consumer to recolor secondary by hand or misuse primary.

Related upstream issue

One component-fit gap from this same migration that isn't in the 10 findings above — CodeBlock can't render per-line add/remove (diff) backgrounds — is already tracked in #3345. I've added an external, real-world side-by-side there (our production diff viewer vs. <CodeBlock highlightLines>, light + dark), and folded the correction into the write-up's "surfaces we KEPT" table.


Environment: @astryxdesign/[email protected], @astryxdesign/[email protected], @astryxdesign/[email protected]; Next 16.2.7 (webpack), React 19.2.7, pnpm 10.29, Node 22. Each finding above was verified against the installed package. Thanks for open-sourcing this — the incremental-adoption story held up on a real app.


Full write-up (all findings with repro commands, measurements, before/after screenshots, and the "what worked well" list): docs/astryx-migration.md in the app we migrated.

Activity

  1. cixzhang commented on Jul 24, 2026

    @cixzhang
    Contributor

    Thanks for this fantastic write up!

    1 -- @imdreamrunner was exploring the stylex dependency. This should be good signal to feed into that.

    6 -- For this one I agree it seems unexpected especially if you were targeting a dark theme in the first place. @ernestt want to get your thoughts on how we should convert accent. One thing to note is that updating the generator can lead to unexpected theme results after upgrading so just to be aware. Maybe the accent color could optionally take in a light-dark array though to be more explicit.

    7 -- Seems reasonable. We could start with it being accent derived. @rubyycheung for thoughts.

    8 -- This is a bug we need to fix.

    9 -- Agree, ideally the composer should accept other inputs and we have mechanisms to enable integrations for custom inputs. Should fix the enter behavior too. I think this is a sort of bug plus missing API.

    10 -- For this one we deliberately left out green/success buttons but definitely interested in hearing more about the requirements in security use cases. Historically the guidance for it was for creation ("pressing this will create an entity") but it ended up getting used for all sorts of other reasons which diluted the meaning of the button. @rubyycheung @ernestt for thoughts on this.

  2. imdreamrunner commented on Jul 24, 2026

    @imdreamrunner
    Contributor

    Great writeup.

    RE 1. Yes I am looking at adding stylex back to dependencies at #3691 i will focus on that PR next week.

    Regarding pnpm, my previous research mistakenly state it always install it by default. Looks like this isn't always true and it's an option.

    pnpm 7.x: depends on the exact minor/patch version
    pnpm 8+: yes, peers auto-install by default

  3. rubyycheung commented on Jul 24, 2026

    @rubyycheung
    Contributor
    1. Just to tack onto Cindy's comment - having more than one primary button also hurts usability. Users should be able to quickly tell what the main action on the page is, and multiple primary buttons make that harder.
  4. ejc3 commented on Jul 24, 2026

    @ejc3
    ContributorAuthor

    Follow-up: the migration is complete — component-fit gaps we hit adopting the wider component set

    Since the original report we finished the migration. Alongside the docs/theme/CLI findings above, here's a
    second batch: component API gaps we found trying to adopt the layout/list/collapsible/badge families.
    Each was verified against the installed dist/ source (not the docs), and each is the specific reason a
    surface stayed hand-written rather than a preference. Framing them as "here's exactly what blocked each
    adoption" in case they're useful for the roadmap.

    Environment as before: @astryxdesign/[email protected], Next 16 (webpack), React 19, pnpm 10.

    1. Item / ListItem can't be a <button> root — so a selectable list row loses its semantics

    Item's element is as?: 'div' | 'li' | 'span' (dist/Item/Item.d.ts) — no button. Our session-list
    row is a <button class="row"> with a leading StatusDot, a title, and trailing badges, and the whole
    row is the click/selection target. With Item we'd either wrap it in our own <button> (nesting the
    Item's interactive children inside a button — invalid) or move the dot/badges to
    startContent/endContent, which drops them from the row's accessible name (connection state becomes
    colour-only) and shrinks the focus target. Ask: a button-rootable list item (or a documented
    "selectable row" recipe) that keeps the selected/pressed state on the focusable element.

    2. Collapsible hides content with display:none → breaks Ctrl-F find-in-page

    dist/Collapsible/Collapsible.js applies a contentHidden class that resolves to
    .x1s85apg { display:none } (in astryx.css), and there is no hidden="until-found" anywhere in the
    package
    (grep -rl 'until-found' dist → 0 files). Our transcript has many collapsed <details> rows
    (tool output, diffs, thinking blocks); display:none content is invisible to browser find-in-page and to
    "scroll to text fragment" deep-links, both of which native <details> (with the modern
    hidden="until-found" upgrade) support. For a log/transcript UI that's a real regression, so we kept
    native <details>. Ask: hidden="until-found" (or a find-in-page-safe collapse) for Collapsible.

    3. CodeBlock highlightLines is a single Set → one highlight colour, so it can't render a diff

    const highlightSet = useMemo(() => highlightLines ? new Set(highlightLines) : null, …)
    (dist/CodeBlock/CodeBlock.js:427). Because every highlighted line goes into one set with one highlight
    style, there's no way to tint added lines green and removed lines red — they'd all get the same colour. No
    sign gutter either. So our +/− diff viewer stayed hand-rolled. Ask: either per-line highlight
    types (Map<lineNo, 'add' | 'del'>) or a dedicated diff mode on CodeBlock. Add/remove is the single
    most common reason to highlight code lines.

    4. Badge has no outline/border variant

    BadgeVariantMap is neutral | info | success | warning | error + 10 hue variants
    (dist/Badge/Badge.d.ts) — all filled/tinted, none outlined. Several of our chips (the harness label, the
    git chip) are quiet outlined pills on a dark surface; a filled Badge reads as a much louder element in
    a dense row. We adopted Badge for the one genuinely-emphatic chip ("needs you" → variant="warning")
    and kept the quiet ones. Ask: an outline (or subtle) Badge variant.

    5. Banner: a module-augmented custom status silently drops its ARIA role

    BannerStatus is extensible via BannerStatusMap augmentation, but the status→role mapping is a fixed
    object
    over the four built-ins (dist/Banner/Banner.js: const statusRole = { info: 'status', warning: 'alert', error: 'alert', success: 'status' }, then role = statusRole[status]). A custom status added by
    augmentation has no entry, so role comes out undefined — a silent accessibility regression that
    TypeScript can't catch (the augmentation only adds the type). Relatedly, there's no neutral/ambient status
    (info forces a blue fill), so a low-key one-line status strip can't use Banner without looking like an
    info alert. We migrated the two real alerts (broker-unreachable, send-failed) to Banner and kept the
    ambient status strip hand-written. Ask: make the status→role (and the icon) map extensible alongside
    BannerStatusMap, and/or add a neutral status.

    6. EmptyState requires a semibold title — no compact "hint" form

    title: string is required (dist/EmptyState/EmptyState.d.ts) and renders semibold/primary. Two of our
    "empty" surfaces are a single faint sentence ("Pick a session…", "No live sessions yet…"), not an
    empty-state moment with an illustration and a heading. Adopting EmptyState would force inventing a
    heading and brightening the copy — a redesign, not a swap — so we kept them. Ask: an isCompact /
    hint variant where the title is optional and the whole thing is one muted line.

    7. SelectableCard is the only selection primitive, and it's a full card

    SelectableCard takes isSelected/onChange and even reflects data-selected (which matched our test
    selector — nice), but it renders a padded astryx-card div. Our question-card answer options are compact
    toggle rows (label + one-line description); three of them as three cards roughly triples the card height on
    a phone. RadioListItem/CheckboxListItem are compact but force a radio/checkbox glyph we don't want.
    Ask: a compact selectable row (label + description, no control glyph) — the middle ground between
    SelectableCard and RadioListItem.


    None of these are blockers for adoption overall — the migration landed, and the button/theme/Markdown
    story was genuinely smooth (Markdown in particular let us drop react-markdown + remark-gfm and came
    with the raw-HTML-escaping and noopener link handling we'd wired by hand). These are the specific edges
    where a real, dense, dark-mode transcript UI met the component set. Happy to expand any of them.

  5. ejc3 commented on Jul 25, 2026

    @ejc3
    ContributorAuthor

    Edited the description to cross-reference #3345 — CodeBlock's per-line add/remove (diff) gap, a component-fit gap from this same migration that wasn't in the 10 findings above. I've added a real-world side-by-side comparison (our diff viewer vs. <CodeBlock highlightLines>, light + dark) over on #3345. Flagging here since issue-body edits don't send a notification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions