dogfooding fixes: adopting Astryx into an existing Next + Tailwind app (guide)#3477
dogfooding fixes: adopting Astryx into an existing Next + Tailwind app (guide)#3477josephfarina wants to merge 1 commit into
Conversation
New `astryx docs adopting-existing-app` guide collecting the integration-boundary traps when adding Astryx to an existing Next.js + Tailwind project: Tailwind preflight silently defeating theme overrides through cascade layers (fix shown for both Tailwind v3 and v4), the required moduleResolution setting, the StyleX build for swizzled components, and type-safe custom variants via defineTheme. Linked from Getting Started. Fixes #3374
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
cixzhang
left a comment
There was a problem hiding this comment.
I see this adds a fairly specific guide for adopting Astryx in one specific condition. There's a few parts here just from cursory read through which I think could also be broken into specific jobs, for example:
Tailwind interop for v4 is documented in our docs but we are missing it for v3. There's a dedicated doc for styling library interop which sounds like it should keep information like this.
We may be missing per framework specific setup instructions. For NextJS there's additional setup like connecting the LinkProvider or setting up the build with stylex that could be useful for the LLM to know so I wonder if we should have a "Setting Up By Framework" article more generically. Were you able to make use of the example apps in resolving some of these?
Theming discovery is interesting but I wonder if that is best discovered via this new article. It seems more broadly useful.
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR No new or modified components detected. Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
What this adds
An "Adopting Astryx in an existing Next.js + Tailwind app" guide —
astryx docs adopting-existing-app— that collects the integration-boundary traps from the #3374 experience report so the next person doesn't rediscover them. Fixes #3374.This is the umbrella issue's remaining work. Two of its items were broken out and are addressed by sibling PRs (linked below); this PR covers the rest and ties them together in one guide.
The guide covers
Trap 1 — Tailwind preflight silently defeats theme overrides (highest impact). Astryx emits component theme overrides in the
astryx-themecascade layer; Tailwind's preflight (@tailwind base) is emitted unlayered, and unlayered rules beat any@layerrule regardless of specificity — so every theme override loses to preflight, with zero errors. The guide gives the fix for both Tailwind versions:@layerorder up front and import Tailwind'stheme/preflight/utilitiesinto named layers (matches the workingapps/example-nextjs-tailwind).@tailwind basein a named layer (@layer tw-preflight { @tailwind base; }).Trap 2 —
moduleResolutionmust bebundler/node16+. Astryx's subpath exports (@astryxdesign/core/Button,/theme, …) don't resolve under the common"moduleResolution": "node". The guide documents the switch and warns it's a project-wide change that can surface latent issues in unrelated deps.Trap 3 — swizzled components need a StyleX compiler. Points at the new "StyleX Build Setup" section in
astryx docs stylingand theapps/example-nextjs-stylexreference (see #3373).Trap 4 — custom variants are type-safe via
defineTheme+theme build. Shows thevariant:override pattern and notes the augmentation now loads automatically (see #3371).Discoverability — a short "start with the CLI" section pointing at
astryx component <Name>,docs tokens,docs styling,docs theme, since most "how do I theme X?" time is spent not knowing the answer already exists in the CLI.Verification
astryx docslists the newadopting-existing-apptopic;astryx docs adopting-existing-apprenders all seven sections.apps/example-nextjs-tailwind/src/app/globals.cssexactly.Related PRs (sibling sub-issues of #3374)