@thanhnguyxn/pixelcraft 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/plugins/marketplace.json +1 -1
- package/.antigravity-plugin/plugin.json +32 -0
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +15 -4
- package/.codex-plugin/plugin.json +45 -0
- package/.cursor-plugin/marketplace.json +17 -0
- package/.cursor-plugin/plugin.json +27 -0
- package/.devin-plugin/plugin.json +21 -0
- package/.github/plugin/marketplace.json +34 -0
- package/CHANGELOG.md +159 -0
- package/GEMINI.md +1 -0
- package/README.md +185 -328
- package/SECURITY.md +28 -0
- package/assets/pixelcraft-logo-128.png +0 -0
- package/assets/pixelcraft-logo-256.png +0 -0
- package/bin/pixelcraft.mjs +431 -23
- package/docs/ARCHITECTURE.md +40 -37
- package/docs/DESIGN-RATIONALE.md +51 -3
- package/docs/INSTALL.md +221 -0
- package/evals/README.md +16 -6
- package/evals/fixtures/3d-web-engineering.json +69 -0
- package/evals/fixtures/acceptance-checklist-rule03-gate.json +43 -0
- package/evals/fixtures/ai-ui-libraries.json +53 -0
- package/evals/fixtures/audio-visual-accessibility.json +69 -0
- package/evals/fixtures/auth-and-checkout-ui.json +53 -0
- package/evals/fixtures/brandkit-identity-governance.json +48 -0
- package/evals/fixtures/build-and-architecture.json +53 -0
- package/evals/fixtures/canvas-and-node-editors.json +53 -0
- package/evals/fixtures/chat-ai-exfiltration-ime-hitl-gate.json +43 -0
- package/evals/fixtures/completion-gate-scan-until-clean.json +44 -0
- package/evals/fixtures/component-systems.json +53 -0
- package/evals/fixtures/component-testing.json +53 -0
- package/evals/fixtures/constrained-voice-and-tv.json +43 -0
- package/evals/fixtures/creative-code-rendering.json +69 -0
- package/evals/fixtures/creative-reference-evidence.json +67 -0
- package/evals/fixtures/data-app-python-marimo.json +49 -0
- package/evals/fixtures/desktop-cpp-juce-audio.json +49 -0
- package/evals/fixtures/desktop-csharp-avalonia.json +49 -0
- package/evals/fixtures/desktop-native-workspace.json +48 -0
- package/evals/fixtures/desktop-python-anti-tkinter.json +49 -0
- package/evals/fixtures/document-prepress-pdfx4-tounicode.json +43 -0
- package/evals/fixtures/document-rust-typst-invoice.json +49 -0
- package/evals/fixtures/document-typst-and-print-css.json +43 -0
- package/evals/fixtures/email-mjml-dark-mode.json +49 -0
- package/evals/fixtures/email-outlook-and-plaintext.json +43 -0
- package/evals/fixtures/enterprise-data-ui.json +53 -0
- package/evals/fixtures/extended-tui-toolkits.json +53 -0
- package/evals/fixtures/extensions-mv3-and-vscode.json +43 -0
- package/evals/fixtures/file-upload-media-ui.json +53 -0
- package/evals/fixtures/forms-validation.json +53 -0
- package/evals/fixtures/game-go-ebitengine.json +49 -0
- package/evals/fixtures/game-godot-gdscript.json +49 -0
- package/evals/fixtures/game-ui-hud-and-engines.json +43 -0
- package/evals/fixtures/i18n-engineering.json +53 -0
- package/evals/fixtures/local-first-sync.json +53 -0
- package/evals/fixtures/lynxjs.json +53 -0
- package/evals/fixtures/maizzle-email.json +53 -0
- package/evals/fixtures/maps-geospatial.json +53 -0
- package/evals/fixtures/media-og-and-video-export.json +43 -0
- package/evals/fixtures/media-players.json +53 -0
- package/evals/fixtures/mobile-compose-16kb-foldable-store-gate.json +44 -0
- package/evals/fixtures/mobile-elixir-liveview-native.json +49 -0
- package/evals/fixtures/mobile-flutter-dynamic-type.json +49 -0
- package/evals/fixtures/mobile-harmonyos-arkui.json +49 -0
- package/evals/fixtures/mobile-jetpack-compose.json +49 -0
- package/evals/fixtures/mobile-swiftui-ios.json +49 -0
- package/evals/fixtures/motion-engineering.json +69 -0
- package/evals/fixtures/pdfjs-and-pptx.json +53 -0
- package/evals/fixtures/plan-discovery-interview.json +31 -0
- package/evals/fixtures/plan-grill-me-brainstorm-gate.json +49 -0
- package/evals/fixtures/reactive-data-apps.json +53 -0
- package/evals/fixtures/review-evidence-audit.json +43 -0
- package/evals/fixtures/rich-text-and-code-editors.json +53 -0
- package/evals/fixtures/scrollytelling-resilience.json +70 -0
- package/evals/fixtures/spatial-xr-comfort-and-platforms.json +43 -0
- package/evals/fixtures/state-architecture.json +53 -0
- package/evals/fixtures/styling-ecosystem.json +53 -0
- package/evals/fixtures/token-tooling.json +53 -0
- package/evals/fixtures/tui-go-bubbletea.json +49 -0
- package/evals/fixtures/tui-rust-ratatui-grapheme-paste-teardown.json +44 -0
- package/evals/fixtures/tui-rust-ratatui.json +49 -0
- package/evals/fixtures/ux-state-matrix-and-i18n.json +43 -0
- package/evals/fixtures/web-3d-engines.json +53 -0
- package/evals/fixtures/web-php-laravel-filament.json +49 -0
- package/evals/fixtures/web-ruby-viewcomponent-phlex.json +49 -0
- package/evals/pixelcraft-accessibility.md +17 -0
- package/evals/pixelcraft-craft.md +16 -0
- package/evals/pixelcraft-dataviz.md +3 -3
- package/evals/pixelcraft-direction.md +17 -0
- package/evals/pixelcraft-game-ui.md +3 -3
- package/evals/pixelcraft-mobile.md +3 -3
- package/evals/pixelcraft-patterns.md +16 -0
- package/evals/pixelcraft-plan.md +65 -3
- package/evals/pixelcraft-review.md +3 -3
- package/evals/pixelcraft-visual-qa.md +11 -5
- package/evals/pixelcraft-web.md +21 -3
- package/evals/pixelcraft.md +4 -4
- package/gemini-extension.json +3 -2
- package/install.ps1 +57 -11
- package/install.sh +82 -7
- package/package.json +32 -4
- package/plugin.json +6 -1
- package/scripts/build-adapters.mjs +11 -13
- package/scripts/run-evals.mjs +397 -0
- package/scripts/sync-docs.mjs +381 -0
- package/scripts/test-build-adapters.mjs +14 -1
- package/scripts/test-cross-platform-qa.mjs +359 -0
- package/scripts/test-distribution.mjs +86 -7
- package/scripts/test-export-tokens.mjs +259 -3
- package/scripts/test-finish-gate.mjs +133 -10
- package/scripts/test-installers.mjs +155 -6
- package/scripts/test-shoot.mjs +23 -1
- package/scripts/test-slop-scan.mjs +390 -3
- package/scripts/test-style-inventory.mjs +23 -0
- package/scripts/test-sync-docs.mjs +140 -0
- package/scripts/test-validate-skills.mjs +82 -4
- package/scripts/validate-skills.mjs +149 -3
- package/skills/pixelcraft/SKILL.md +67 -47
- package/skills/pixelcraft/references/design-brief.md +2 -2
- package/skills/pixelcraft/references/floor.md +36 -19
- package/skills/pixelcraft/references/report-template.md +25 -11
- package/skills/pixelcraft/references/stack-detection.md +138 -67
- package/skills/pixelcraft/references/surface-acceptance.md +33 -21
- package/skills/pixelcraft/references/workflow-checkpoints.md +49 -7
- package/skills/pixelcraft-accessibility/SKILL.md +34 -13
- package/skills/pixelcraft-accessibility/references/apg-patterns.md +13 -0
- package/skills/pixelcraft-accessibility/references/motion-canvas.md +57 -0
- package/skills/pixelcraft-accessibility/references/platforms.md +34 -6
- package/skills/pixelcraft-accessibility/references/verification.md +15 -10
- package/skills/pixelcraft-accessibility/references/wcag22-checks.md +38 -5
- package/skills/pixelcraft-brandkit/SKILL.md +42 -30
- package/skills/pixelcraft-brandkit/references/asset-pipeline.md +90 -50
- package/skills/pixelcraft-brandkit/references/brand-governance.md +29 -27
- package/skills/pixelcraft-brandkit/references/logo-methods.md +33 -34
- package/skills/pixelcraft-brandkit/references/prompt-template.md +53 -51
- package/skills/pixelcraft-brandkit/references/qa-checklist.md +7 -2
- package/skills/pixelcraft-brandkit/references/visual-modes.md +16 -16
- package/skills/pixelcraft-chat-ui/SKILL.md +31 -27
- package/skills/pixelcraft-chat-ui/references/agentic-workspace.md +66 -0
- package/skills/pixelcraft-chat-ui/references/ai-ui-libraries.md +259 -0
- package/skills/pixelcraft-chat-ui/references/conversation-design.md +12 -6
- package/skills/pixelcraft-chat-ui/references/mobile-business-platforms.md +58 -68
- package/skills/pixelcraft-chat-ui/references/slack-discord.md +60 -76
- package/skills/pixelcraft-constrained/SKILL.md +21 -20
- package/skills/pixelcraft-constrained/references/specialized-hardware.md +69 -45
- package/skills/pixelcraft-constrained/references/tv-wearables.md +123 -73
- package/skills/pixelcraft-constrained/references/voice-ui.md +86 -45
- package/skills/pixelcraft-craft/SKILL.md +29 -15
- package/skills/pixelcraft-craft/references/color.md +62 -6
- package/skills/pixelcraft-craft/references/layout.md +32 -0
- package/skills/pixelcraft-craft/references/motion.md +99 -12
- package/skills/pixelcraft-craft/references/typography.md +48 -9
- package/skills/pixelcraft-data-apps/SKILL.md +50 -31
- package/skills/pixelcraft-data-apps/references/ai-and-internal-data-apps.md +147 -0
- package/skills/pixelcraft-data-apps/references/dash.md +87 -31
- package/skills/pixelcraft-data-apps/references/evidence.md +41 -26
- package/skills/pixelcraft-data-apps/references/gradio.md +65 -27
- package/skills/pixelcraft-data-apps/references/julia-genie.md +64 -29
- package/skills/pixelcraft-data-apps/references/jupyter-widgets.md +65 -27
- package/skills/pixelcraft-data-apps/references/nicegui.md +73 -34
- package/skills/pixelcraft-data-apps/references/observable-framework.md +65 -27
- package/skills/pixelcraft-data-apps/references/panel.md +69 -23
- package/skills/pixelcraft-data-apps/references/r-shiny.md +104 -34
- package/skills/pixelcraft-data-apps/references/reactive-data-apps.md +186 -0
- package/skills/pixelcraft-data-apps/references/reflex.md +85 -31
- package/skills/pixelcraft-data-apps/references/shiny.md +84 -27
- package/skills/pixelcraft-data-apps/references/streamlit.md +73 -25
- package/skills/pixelcraft-dataviz/SKILL.md +21 -24
- package/skills/pixelcraft-dataviz/references/color-accessibility.md +2 -2
- package/skills/pixelcraft-dataviz/references/encoding-tables-dashboards.md +35 -25
- package/skills/pixelcraft-dataviz/references/libraries.md +165 -46
- package/skills/pixelcraft-dataviz/references/maps-geospatial.md +159 -0
- package/skills/pixelcraft-dataviz/references/realtime-graphs-maps-scale.md +58 -65
- package/skills/pixelcraft-desktop/SKILL.md +61 -39
- package/skills/pixelcraft-desktop/references/appkit.md +60 -26
- package/skills/pixelcraft-desktop/references/avalonia.md +65 -29
- package/skills/pixelcraft-desktop/references/cpp-gui.md +104 -27
- package/skills/pixelcraft-desktop/references/electron.md +68 -26
- package/skills/pixelcraft-desktop/references/go-gui.md +59 -30
- package/skills/pixelcraft-desktop/references/gtk.md +74 -31
- package/skills/pixelcraft-desktop/references/javafx-swing.md +54 -25
- package/skills/pixelcraft-desktop/references/qt-pyside-qml.md +57 -30
- package/skills/pixelcraft-desktop/references/rust-gui.md +59 -41
- package/skills/pixelcraft-desktop/references/tauri.md +80 -24
- package/skills/pixelcraft-desktop/references/uno-platform.md +42 -23
- package/skills/pixelcraft-desktop/references/winui-wpf.md +66 -26
- package/skills/pixelcraft-desktop/references/working-context.md +82 -3
- package/skills/pixelcraft-direction/SKILL.md +48 -82
- package/skills/pixelcraft-direction/references/creative-brainstorming.md +72 -0
- package/skills/pixelcraft-direction/references/direction-card.md +11 -1
- package/skills/pixelcraft-direction/references/direction-scoring.md +5 -1
- package/skills/pixelcraft-direction/references/motion-identity.md +67 -0
- package/skills/pixelcraft-direction/references/movements.md +3 -0
- package/skills/pixelcraft-direction/references/reference-analysis.md +37 -0
- package/skills/pixelcraft-direction/references/slop-fingerprints.md +32 -7
- package/skills/pixelcraft-document/SKILL.md +27 -23
- package/skills/pixelcraft-document/references/archetypes.md +27 -4
- package/skills/pixelcraft-document/references/pdf-tools.md +241 -81
- package/skills/pixelcraft-document/references/pdfjs-and-pptx.md +114 -0
- package/skills/pixelcraft-document/references/print-css.md +96 -43
- package/skills/pixelcraft-document/references/slides.md +123 -27
- package/skills/pixelcraft-email/SKILL.md +42 -20
- package/skills/pixelcraft-email/references/client-quirks.md +101 -33
- package/skills/pixelcraft-email/references/html-tables.md +83 -22
- package/skills/pixelcraft-email/references/maizzle.md +54 -0
- package/skills/pixelcraft-email/references/mjml.md +13 -11
- package/skills/pixelcraft-email/references/react-email.md +76 -34
- package/skills/pixelcraft-extensions/SKILL.md +32 -27
- package/skills/pixelcraft-extensions/references/browser-extensions.md +91 -17
- package/skills/pixelcraft-extensions/references/figma-office.md +97 -14
- package/skills/pixelcraft-extensions/references/ide-and-saas-plugins.md +125 -0
- package/skills/pixelcraft-extensions/references/raycast.md +90 -11
- package/skills/pixelcraft-extensions/references/vscode-webviews.md +91 -17
- package/skills/pixelcraft-game-ui/SKILL.md +45 -26
- package/skills/pixelcraft-game-ui/references/bevy.md +69 -31
- package/skills/pixelcraft-game-ui/references/godot.md +100 -27
- package/skills/pixelcraft-game-ui/references/hud-principles.md +50 -21
- package/skills/pixelcraft-game-ui/references/love2d.md +53 -27
- package/skills/pixelcraft-game-ui/references/monogame.md +45 -29
- package/skills/pixelcraft-game-ui/references/unity-ugui.md +109 -0
- package/skills/pixelcraft-game-ui/references/unity-ui-toolkit.md +69 -27
- package/skills/pixelcraft-game-ui/references/unreal-umg.md +53 -26
- package/skills/pixelcraft-game-ui/references/web-and-middleware-game-ui.md +122 -0
- package/skills/pixelcraft-handoff/SKILL.md +14 -13
- package/skills/pixelcraft-handoff/references/design-translation.md +40 -10
- package/skills/pixelcraft-handoff/references/motion-handoff.md +54 -0
- package/skills/pixelcraft-media/SKILL.md +20 -23
- package/skills/pixelcraft-media/references/banners-video.md +83 -65
- package/skills/pixelcraft-media/references/og-generation.md +110 -63
- package/skills/pixelcraft-media/references/social-cards.md +57 -58
- package/skills/pixelcraft-mobile/SKILL.md +53 -36
- package/skills/pixelcraft-mobile/references/dotnet-maui.md +62 -34
- package/skills/pixelcraft-mobile/references/flet.md +53 -26
- package/skills/pixelcraft-mobile/references/flutter.md +76 -32
- package/skills/pixelcraft-mobile/references/harmonyos-and-emerging-mobile.md +121 -0
- package/skills/pixelcraft-mobile/references/ionic-capacitor.md +48 -26
- package/skills/pixelcraft-mobile/references/jetpack-compose.md +92 -24
- package/skills/pixelcraft-mobile/references/kivy.md +54 -31
- package/skills/pixelcraft-mobile/references/kotlin-multiplatform.md +53 -27
- package/skills/pixelcraft-mobile/references/lynxjs.md +110 -0
- package/skills/pixelcraft-mobile/references/nativescript-and-skip.md +91 -0
- package/skills/pixelcraft-mobile/references/react-native-expo.md +66 -31
- package/skills/pixelcraft-mobile/references/swiftui.md +158 -28
- package/skills/pixelcraft-mobile/references/tactile-interactions.md +55 -0
- package/skills/pixelcraft-mobile/references/task-state-composition.md +82 -2
- package/skills/pixelcraft-mobile/references/uikit.md +57 -23
- package/skills/pixelcraft-patterns/SKILL.md +30 -13
- package/skills/pixelcraft-patterns/references/accessibility-resilience.md +29 -0
- package/skills/pixelcraft-patterns/references/ai-and-offline-patterns.md +54 -0
- package/skills/pixelcraft-patterns/references/auth-onboarding.md +32 -13
- package/skills/pixelcraft-patterns/references/billing-paywalls.md +40 -0
- package/skills/pixelcraft-patterns/references/command-workspace.md +56 -0
- package/skills/pixelcraft-patterns/references/commerce.md +35 -16
- package/skills/pixelcraft-patterns/references/communication.md +34 -15
- package/skills/pixelcraft-patterns/references/creative-tools.md +30 -17
- package/skills/pixelcraft-patterns/references/creative-web-composition.md +38 -0
- package/skills/pixelcraft-patterns/references/dashboard-admin.md +22 -18
- package/skills/pixelcraft-patterns/references/history-diff-undo.md +50 -0
- package/skills/pixelcraft-patterns/references/marketing.md +31 -19
- package/skills/pixelcraft-patterns/references/multi-tenant-rbac.md +47 -0
- package/skills/pixelcraft-patterns/references/narrative-systems.md +42 -0
- package/skills/pixelcraft-patterns/references/notifications-activity.md +57 -0
- package/skills/pixelcraft-patterns/references/pattern-selection.md +8 -2
- package/skills/pixelcraft-patterns/references/scheduling-kanban.md +47 -0
- package/skills/pixelcraft-patterns/references/scroll-implementation.md +37 -0
- package/skills/pixelcraft-patterns/references/settings.md +40 -12
- package/skills/pixelcraft-plan/SKILL.md +54 -18
- package/skills/pixelcraft-plan/references/discovery-interview.md +110 -0
- package/skills/pixelcraft-plan/references/grill-me-protocol.md +63 -0
- package/skills/pixelcraft-plan/references/plan-template.md +44 -9
- package/skills/pixelcraft-plan/references/repo-discovery.md +16 -9
- package/skills/pixelcraft-plan/references/stack-freshness.md +22 -5
- package/skills/pixelcraft-plan/references/stack-selection.md +65 -9
- package/skills/pixelcraft-review/SKILL.md +41 -19
- package/skills/pixelcraft-review/references/audit-report.md +20 -1
- package/skills/pixelcraft-review/references/heuristics.md +63 -18
- package/skills/pixelcraft-review/references/personas.md +41 -14
- package/skills/pixelcraft-review/references/polish.md +66 -26
- package/skills/pixelcraft-review/scripts/check-acceptance.mjs +619 -0
- package/skills/pixelcraft-review/scripts/fixtures/focus-longhand-removal.css +34 -0
- package/skills/pixelcraft-review/scripts/slop-scan.mjs +679 -32
- package/skills/pixelcraft-spatial/SKILL.md +16 -17
- package/skills/pixelcraft-spatial/references/comfort-accessibility.md +25 -84
- package/skills/pixelcraft-spatial/references/platforms.md +123 -53
- package/skills/pixelcraft-tokens/SKILL.md +18 -14
- package/skills/pixelcraft-tokens/assets/tokens.example.json +1 -1
- package/skills/pixelcraft-tokens/assets/tokens.modes.example.json +1 -1
- package/skills/pixelcraft-tokens/references/format.md +39 -9
- package/skills/pixelcraft-tokens/references/governance.md +1 -1
- package/skills/pixelcraft-tokens/references/theme-presets.md +36 -8
- package/skills/pixelcraft-tokens/references/token-tooling.md +119 -0
- package/skills/pixelcraft-tokens/scripts/export-tokens.mjs +637 -75
- package/skills/pixelcraft-tui/SKILL.md +41 -25
- package/skills/pixelcraft-tui/references/bubbletea-lipgloss.md +49 -30
- package/skills/pixelcraft-tui/references/extended-tui-toolkits.md +127 -0
- package/skills/pixelcraft-tui/references/ink.md +77 -28
- package/skills/pixelcraft-tui/references/ratatui.md +70 -30
- package/skills/pixelcraft-tui/references/rich.md +53 -33
- package/skills/pixelcraft-tui/references/terminal-protocols.md +80 -0
- package/skills/pixelcraft-tui/references/textual.md +75 -34
- package/skills/pixelcraft-ux/SKILL.md +22 -12
- package/skills/pixelcraft-ux/references/feedback-performance.md +39 -19
- package/skills/pixelcraft-ux/references/forms.md +57 -3
- package/skills/pixelcraft-ux/references/i18n.md +50 -12
- package/skills/pixelcraft-ux/references/laws.md +35 -14
- package/skills/pixelcraft-ux/references/state-matrix.md +15 -1
- package/skills/pixelcraft-ux/references/ux-writing.md +1 -0
- package/skills/pixelcraft-visual-qa/SKILL.md +21 -7
- package/skills/pixelcraft-visual-qa/references/capture-desktop-game.md +28 -7
- package/skills/pixelcraft-visual-qa/references/capture-document.md +70 -0
- package/skills/pixelcraft-visual-qa/references/capture-email.md +13 -9
- package/skills/pixelcraft-visual-qa/references/capture-mobile.md +20 -5
- package/skills/pixelcraft-visual-qa/references/capture-terminal.md +6 -2
- package/skills/pixelcraft-visual-qa/references/motion-capture.md +63 -0
- package/skills/pixelcraft-visual-qa/references/performance-budgets.md +25 -12
- package/skills/pixelcraft-visual-qa/references/realtime-graphics.md +55 -0
- package/skills/pixelcraft-visual-qa/scripts/check-contrast.mjs +442 -0
- package/skills/pixelcraft-visual-qa/scripts/check-email.mjs +397 -0
- package/skills/pixelcraft-visual-qa/scripts/check-pdf.mjs +189 -0
- package/skills/pixelcraft-visual-qa/scripts/check-tui.mjs +321 -0
- package/skills/pixelcraft-visual-qa/scripts/finish-gate.mjs +50 -11
- package/skills/pixelcraft-visual-qa/scripts/shoot.mjs +214 -59
- package/skills/pixelcraft-visual-qa/scripts/style-inventory.mjs +121 -49
- package/skills/pixelcraft-web/SKILL.md +105 -49
- package/skills/pixelcraft-web/references/accessibility-performance.md +42 -0
- package/skills/pixelcraft-web/references/adaptive-layout.md +52 -8
- package/skills/pixelcraft-web/references/angular.md +63 -16
- package/skills/pixelcraft-web/references/assets-pipeline.md +67 -0
- package/skills/pixelcraft-web/references/astro.md +64 -13
- package/skills/pixelcraft-web/references/audio-reactive.md +61 -0
- package/skills/pixelcraft-web/references/auth-and-checkout-ui.md +115 -0
- package/skills/pixelcraft-web/references/build-and-architecture.md +215 -0
- package/skills/pixelcraft-web/references/canvas-and-node-editors.md +157 -0
- package/skills/pixelcraft-web/references/clojurescript.md +52 -17
- package/skills/pixelcraft-web/references/component-systems.md +102 -0
- package/skills/pixelcraft-web/references/component-testing.md +170 -0
- package/skills/pixelcraft-web/references/creative-effects.md +59 -0
- package/skills/pixelcraft-web/references/creative-runtime.md +34 -0
- package/skills/pixelcraft-web/references/enterprise-data-ui.md +138 -0
- package/skills/pixelcraft-web/references/file-upload-media-ui.md +82 -0
- package/skills/pixelcraft-web/references/forms-validation.md +123 -0
- package/skills/pixelcraft-web/references/fsharp-fable.md +3 -2
- package/skills/pixelcraft-web/references/gsap.md +102 -0
- package/skills/pixelcraft-web/references/html-css.md +144 -12
- package/skills/pixelcraft-web/references/htmx-alpine.md +68 -18
- package/skills/pixelcraft-web/references/i18n-engineering.md +106 -0
- package/skills/pixelcraft-web/references/interaction-and-search-primitives.md +196 -0
- package/skills/pixelcraft-web/references/java-web.md +27 -18
- package/skills/pixelcraft-web/references/kotlin-web.md +6 -2
- package/skills/pixelcraft-web/references/leptos-yew.md +62 -19
- package/skills/pixelcraft-web/references/lit-web-components.md +4 -2
- package/skills/pixelcraft-web/references/local-first-sync.md +105 -0
- package/skills/pixelcraft-web/references/media-players.md +104 -0
- package/skills/pixelcraft-web/references/motion-react.md +96 -0
- package/skills/pixelcraft-web/references/motion-recipes.md +82 -0
- package/skills/pixelcraft-web/references/preact-fresh-hono.md +111 -0
- package/skills/pixelcraft-web/references/pwa.md +6 -1
- package/skills/pixelcraft-web/references/qwik.md +51 -11
- package/skills/pixelcraft-web/references/r3f-integration.md +69 -0
- package/skills/pixelcraft-web/references/react-next.md +112 -13
- package/skills/pixelcraft-web/references/rendering-choice.md +63 -0
- package/skills/pixelcraft-web/references/rendering-performance.md +80 -0
- package/skills/pixelcraft-web/references/rich-text-and-code-editors.md +220 -0
- package/skills/pixelcraft-web/references/rive-lottie.md +73 -0
- package/skills/pixelcraft-web/references/scene-architecture.md +132 -0
- package/skills/pixelcraft-web/references/server-rendered.md +106 -63
- package/skills/pixelcraft-web/references/shader-workflow.md +77 -0
- package/skills/pixelcraft-web/references/smooth-scroll.md +58 -0
- package/skills/pixelcraft-web/references/solid.md +67 -16
- package/skills/pixelcraft-web/references/state-architecture.md +107 -0
- package/skills/pixelcraft-web/references/styling-ecosystem.md +273 -0
- package/skills/pixelcraft-web/references/svelte.md +61 -11
- package/skills/pixelcraft-web/references/tailwind.md +40 -14
- package/skills/pixelcraft-web/references/video-media.md +69 -0
- package/skills/pixelcraft-web/references/vue-nuxt.md +37 -13
- package/skills/pixelcraft-web/references/web-3d-engines.md +97 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# State management and frontend data architecture
|
|
2
|
+
|
|
3
|
+
Do not put every piece of application state into one global store. Classify state by **ownership, lifetime, shareability, and failure mode**, then choose the smallest tool that fits each layer.
|
|
4
|
+
|
|
5
|
+
## Five-layer state classification
|
|
6
|
+
|
|
7
|
+
| Layer | Examples | Primary tools | Anti-pattern to avoid |
|
|
8
|
+
|---|---|---|---|
|
|
9
|
+
| **Local UI state** | Open popover, hover index, accordion, ephemeral draft | Framework state (`useState`, signals, runes) | Lifting transient widget state into a global store |
|
|
10
|
+
| **URL / navigation state** | Active filters, sort, pagination, selected tab/item, modal deep-link | `nuqs` (v2), TanStack Router search params, native `URLSearchParams` | Storing shareable filter/tab state only in memory so reload resets it |
|
|
11
|
+
| **Server / async cache state** | REST/RPC/GraphQL entities, pagination, background refetch, mutations | TanStack Query (v5), **TanStack DB**, SWR, RTK Query; typed RPC: **tRPC v11**, **oRPC**, **Hono RPC (`hc`)**; GraphQL: Apollo Client, Relay, urql | Copying fetched API payloads into Redux/Zustand/Pinia and manually managing loading/stale flags |
|
|
12
|
+
| **Cross-tree client & workflow state** | Active tool, workspace panels, multi-step checkout, upload/retry machines | React: Zustand v5, Jotai, Redux Toolkit, Legend-State, TanStack Store; Vue: **Pinia**; Angular: **NgRx SignalStore**; workflows: **XState v5**, RxJS | Tangled boolean flags (`isLoading && !isError && isRetrying`) allowing impossible states |
|
|
13
|
+
| **Local persistent / offline state** | Drafts, offline queues, large client datasets, user prefs | Dexie.js (`IndexedDB`), **`idb` / `idb-keyval`** (tiny Promise wrappers over IndexedDB), OPFS (blobs), `localStorage` (small prefs) | Storing megabytes or structured queryable records in synchronous `localStorage` or unmaintained `localForage` |
|
|
14
|
+
|
|
15
|
+
## Server-state, typed RPC, and GraphQL clients
|
|
16
|
+
|
|
17
|
+
- **React 19 native action hooks (`useActionState`, `useOptimistic`)**: use for component-scoped mutation lifecycles and transient optimistic UI overrides during form/action submission. They have **no global cache, deduplication, or background refetching**—they complement rather than replace TanStack Query (server cache) or Zustand (cross-tree client UI store).
|
|
18
|
+
- **REST & typed RPC**: use **TanStack Query v5** (React/Vue/Solid/Svelte/Angular) for structured caching, stale-while-revalidate, dependent queries, and optimistic mutations; pair with **tRPC v11** (native `queryOptions` / `mutationOptions` integration with TanStack Query), **oRPC** (OpenAPI-first Standard Schema typed RPC), or **Hono RPC (`hc<AppType>`)** for end-to-end TypeScript safety without codegen. Use **TanStack DB** when you need reactive client-side normalized collections, live cross-collection joins, and instant optimistic mutations backed by TanStack Query or sync engines (`local-first-sync.md`).
|
|
19
|
+
- **GraphQL**: use **Apollo Client** for normalized cache + local reactive variables; **Relay** when strict fragment colocation and compiler-enforced data masking justify the build step; **urql** for lightweight extensible document/graph caching.
|
|
20
|
+
- **Optimistic mutation contract**: always `cancelQueries` before mutating cache so in-flight refetches cannot overwrite optimistic data, snapshot previous data for `onError` rollback, and `invalidateQueries` in `onSettled`:
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
// TanStack Query v5 optimistic update with rollback
|
|
24
|
+
const mutation = useMutation({
|
|
25
|
+
mutationFn: updateItem,
|
|
26
|
+
onMutate: async (nextItem) => {
|
|
27
|
+
await queryClient.cancelQueries({ queryKey: ['items'] });
|
|
28
|
+
const previous = queryClient.getQueryData<Item[]>(['items']);
|
|
29
|
+
queryClient.setQueryData<Item[]>(['items'], (old = []) => [...old, nextItem]);
|
|
30
|
+
return { previous };
|
|
31
|
+
},
|
|
32
|
+
onError: (_err, _vars, ctx) => {
|
|
33
|
+
queryClient.setQueryData(['items'], ctx?.previous);
|
|
34
|
+
},
|
|
35
|
+
onSettled: () => queryClient.invalidateQueries({ queryKey: ['items'] }),
|
|
36
|
+
});
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Client UI state and SSR isolation
|
|
40
|
+
|
|
41
|
+
- **React**: **Zustand v5** (select narrow slices with `useShallow` or primitive selectors), **Jotai** (atomic bottom-up derived graphs), **Redux Toolkit** (strict action logs/middleware), **Legend-State** (fine-grained signal-like observable state with optional sync persistence), **TanStack Store** (framework-agnostic minimal reactive store), or MobX/Valtio.
|
|
42
|
+
- **Vue / Nuxt**: **Pinia** (`defineStore('filters', () => { ... })` setup stores) registered per SSR app instance; pair with Nuxt `useState()` for simple request-scoped primitives (`vue-nuxt.md`).
|
|
43
|
+
- **Angular**: **NgRx SignalStore (`@ngrx/signals`)** (`signalStore(withState, withComputed, withMethods)`) for modular signal-first feature state (`angular.md`).
|
|
44
|
+
- **Svelte 5**: rune classes in `.svelte.ts` instantiated in root layout and shared via `setContext`/`getContext` (`svelte.md`).
|
|
45
|
+
- **SSR / Next.js critical rule**: never share a module-level singleton store across concurrent server requests, and never read/write client stores from React Server Components. Instantiate stores per-request via a client Context provider (`createStore` from `zustand/vanilla` initialized inside `useState(() => createAppStore())`).
|
|
46
|
+
|
|
47
|
+
## Complex workflows (XState v5) and RxJS
|
|
48
|
+
|
|
49
|
+
- Use **XState v5** when a flow has explicit finite states, guards, cancellation, retries, or parallel regions. Use `setup({ types, actors: { ...: fromPromise(...) } }).createMachine(...)` (not v4's two-argument `createMachine`) and read snapshots in React with `useSelector(actorRef, selector)` + `actorRef.send(event)`.
|
|
50
|
+
- Use **RxJS** only when composing complex asynchronous event streams (cancellation via `switchMap`, backpressure, WebSocket multiplexing) where simple promises/effects become race-prone.
|
|
51
|
+
|
|
52
|
+
## URL-as-State (`nuqs` v2 / typed router params) & network race cancellation
|
|
53
|
+
|
|
54
|
+
- **URL-as-State completeness**: serialize search queries (`?q=`), active filters, sort column/direction (`?sort=created_at:desc`), pagination/cursor, active tab, and shareable inspector/drawer IDs (`?invoice=inv_1042`) into URL query/path so page reload, browser Back/Forward, and shared links reproduce the exact view without trapped memory state.
|
|
55
|
+
- Wrap App Router / SPA roots in the matching `<NuqsAdapter>` and choose `history: 'replace'` (throttled) for high-frequency typing/sliders vs `history: 'push'` for discrete facet, tab, pagination, or drawer navigation steps.
|
|
56
|
+
- **Query cancellation (`AbortController`)**: forward TanStack Query's `signal` (`queryFn: ({ signal }) => fetch(url, { signal })`) or an explicit `AbortController` on rapid search/filter/tenant transitions so a slow 800 ms response for an earlier filter never overwrites a fast 90 ms response for the latest filter.
|
|
57
|
+
|
|
58
|
+
```tsx
|
|
59
|
+
const [view, setView] = useQueryStates(
|
|
60
|
+
{
|
|
61
|
+
q: parseAsString.withDefault(''),
|
|
62
|
+
sort: parseAsStringLiteral(['newest', 'amount'] as const).withDefault('newest'),
|
|
63
|
+
page: parseAsInteger.withDefault(1),
|
|
64
|
+
drawerId: parseAsString,
|
|
65
|
+
},
|
|
66
|
+
{ history: 'replace' }
|
|
67
|
+
);
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Multi-tab auth & tenant synchronization (`BroadcastChannel` + `storage`)
|
|
71
|
+
|
|
72
|
+
Users routinely keep 5–10 SaaS tabs open. If Tab B signs out, refreshes tokens, or switches active workspace/organization (`org_acme` → `org_globex`), background Tab A must react immediately—otherwise Tab A will display stale UI or fire mutations into the wrong tenant:
|
|
73
|
+
|
|
74
|
+
- Scope every server-cache key by tenant (`['org', activeOrgId, 'projects', filters]`) rather than global `['projects']`.
|
|
75
|
+
- Broadcast `SIGN_OUT`, `SESSION_REFRESHED`, and `ORG_CHANGED` over `BroadcastChannel` (with `window.addEventListener('storage', ...)` fallback where needed) so sibling tabs clear/re-scope caches immediately or prompt before overwriting unsaved drafts:
|
|
76
|
+
|
|
77
|
+
```ts
|
|
78
|
+
type AuthSyncMessage =
|
|
79
|
+
| { type: 'SIGN_OUT' }
|
|
80
|
+
| { type: 'ORG_CHANGED'; orgId: string };
|
|
81
|
+
|
|
82
|
+
export function connectMultiTabSync(onEvent: (msg: AuthSyncMessage) => void) {
|
|
83
|
+
if (typeof BroadcastChannel === 'undefined') return () => {};
|
|
84
|
+
const channel = new BroadcastChannel('app:auth-tenant-sync');
|
|
85
|
+
channel.onmessage = (e: MessageEvent<AuthSyncMessage>) => onEvent(e.data);
|
|
86
|
+
return {
|
|
87
|
+
post: (msg: AuthSyncMessage) => channel.postMessage(msg),
|
|
88
|
+
close: () => channel.close(),
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Local persistence (Dexie / `idb` / `idb-keyval`)
|
|
94
|
+
|
|
95
|
+
- Use **IndexedDB** via **Dexie.js** (`useLiveQuery` in React) for structured queryable offline datasets and multi-megabyte caches, or **`idb` / `idb-keyval`** for lightweight typed Promise key-value storage (avoid unmaintained `localForage`). Reserve `localStorage` for tiny non-sensitive preferences (`< 50 KB`) and never store auth secrets there.
|
|
96
|
+
- In Dexie `.stores()`, declare **only indexed columns** (non-indexed fields are still stored automatically). **Never modify a shipped `db.version(N)` block that has an `.upgrade(tx => ...)` callback**—always append `db.version(N + 1)` for schema migrations.
|
|
97
|
+
|
|
98
|
+
## Do/don't pairs
|
|
99
|
+
|
|
100
|
+
| Do | Don't |
|
|
101
|
+
|---|---|
|
|
102
|
+
| Keep API entities in TanStack Query / tRPC v11 / oRPC / Apollo (keyed by `orgId` + `signal`) and UI toggles in Zustand / Pinia / SignalStore | Mirror fetched server data into a global store or omit `AbortSignal` on rapid filter fetches |
|
|
103
|
+
| Instantiate Zustand / Svelte rune / Pinia stores per request in SSR frameworks | Export a global singleton store mutated during SSR requests |
|
|
104
|
+
| Propagate sign-out and workspace/tenant switches across tabs via `BroadcastChannel` | Let background tabs stay logged in after sign-out or write mutations to a stale tenant |
|
|
105
|
+
| Use XState v5 `setup().createMachine()` + `useSelector` for multi-step retry/cancel flows | Stack 6 booleans (`loading`, `retrying`, `failed`, `cancelled`) that allow invalid states |
|
|
106
|
+
| Serialize search, filters, sort, pagination, tabs, and shareable drawer IDs in the URL (`useQueryStates`) | Store filter/drawer state only in memory or serialize sensitive tokens into `window.location.search` |
|
|
107
|
+
| Use Dexie (append `db.version(N + 1)` for migrations) or `idb`/`idb-keyval` for offline storage | Add unmaintained `localForage`, edit shipped Dexie `.version(N)` upgrades, or stuff MBs into `localStorage` |
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
# Styling and CSS ecosystem
|
|
2
|
+
|
|
3
|
+
Select the styling layer by runtime model, React Server Components (RSC) compatibility, theming contract, and team ownership—not habit. For Tailwind v4 CSS-first `@theme inline` rules, read [tailwind.md](tailwind.md); for pure native HTML/CSS features (`@layer`, Popover, Anchor Positioning, `@starting-style`, `oklch`), read [html-css.md](html-css.md).
|
|
4
|
+
|
|
5
|
+
## Architecture decision matrix
|
|
6
|
+
|
|
7
|
+
| Model | Representative tools | Build-time CSS | RSC-safe | Best fit | Primary trade-off |
|
|
8
|
+
|---|---|---|---|---|---|
|
|
9
|
+
| Native CSS & Modules | CSS Modules, **Lightning CSS**, PostCSS | Yes | Yes | Any framework, minimal tooling, long-lived apps | Manual token/variant ergonomics unless paired with CVA |
|
|
10
|
+
| Preprocessors | Sass/SCSS (`@use`/`@forward`), Less | Yes | Yes | Existing SCSS/Bootstrap/Carbon codebases | Largely superseded by native CSS nesting, custom properties, and `@layer` for greenfield work |
|
|
11
|
+
| Utility / Token CSS | Tailwind CSS v4, UnoCSS, Open Props, Bootstrap, Bulma | Yes | Yes | Rapid composition, multi-surface products, server-rendered apps | Requires strict semantic token bridge to avoid utility soup |
|
|
12
|
+
| Zero-runtime CSS-in-TS | Panda CSS, vanilla-extract, **Pigment CSS**, Linaria (WyW-in-JS) | Yes | Yes | Type-safe design systems, strict token contracts, RSC apps (Pigment CSS for MUI v6/v7 RSC migrations) | Static-extraction constraints (no arbitrary runtime expressions) |
|
|
13
|
+
| Compiled Atomic JS | StyleX (`@stylexjs/stylex`), **Tamagui Web** | Yes | Yes | Meta-scale deterministic atomic CSS (StyleX); shared React Web + React Native UI with optimizing extraction (Tamagui) | Strict compiler/file rules and bundler plugin setup |
|
|
14
|
+
| Runtime CSS-in-JS | Emotion, styled-components | No (runtime injection) | No (`'use client'` + registry required) | Legacy React SPAs or MUI v5 / Chakra v2 maintenance | Serialization, hydration, and RSC overhead; avoid for new RSC apps |
|
|
15
|
+
|
|
16
|
+
Never stack two competing styling paradigms in the same surface (for example, Bootstrap + Tailwind or Emotion + Panda CSS) unless executing an explicit incremental migration behind `@layer`.
|
|
17
|
+
|
|
18
|
+
## Zero-runtime build-time CSS-in-TS
|
|
19
|
+
|
|
20
|
+
### Panda CSS
|
|
21
|
+
|
|
22
|
+
Panda CSS statically analyzes source files at build time and emits atomic CSS. Any value Panda cannot resolve statically produces a class name with **no emitted CSS** (silent failure).
|
|
23
|
+
|
|
24
|
+
- **Static extraction rule**: never pass runtime variables, dynamic object keys, spreads, or template literals (`red.${shade}`) into `css()`. Both branches of a ternary must be literal token values.
|
|
25
|
+
- **Dynamic values**: map runtime choices to precomputed `css()` objects, use `cva`/`sva` recipes, or declare `staticCss` in `defineConfig()` for dynamic recipe variants.
|
|
26
|
+
- **Theming**: define semantic tokens with `{ base, _dark }` conditions instead of runtime theme-switching Context.
|
|
27
|
+
- **Multi-part components**: use `sva()` and always list `slots` explicitly so typos fail at compile time instead of creating silent extra slots.
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
// panda.config.ts (excerpt)
|
|
31
|
+
semanticTokens: {
|
|
32
|
+
colors: {
|
|
33
|
+
bg: {
|
|
34
|
+
canvas: { value: { base: '#ffffff', _dark: '#0a0a0a' } },
|
|
35
|
+
subtle: { value: { base: '#f5f5f5', _dark: '#1a1a1a' } },
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
staticCss: {
|
|
40
|
+
recipes: {
|
|
41
|
+
button: [{ size: ['sm', 'md'] }, { variant: ['*'] }],
|
|
42
|
+
},
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
```tsx
|
|
47
|
+
import { css, sva } from '../styled-system/css';
|
|
48
|
+
|
|
49
|
+
// Both ternary branches are statically extractable literals
|
|
50
|
+
const labelClass = css({ color: isActive ? 'text.default' : 'text.muted' });
|
|
51
|
+
|
|
52
|
+
// Multi-slot recipe with explicit slots
|
|
53
|
+
const card = sva({
|
|
54
|
+
slots: ['root', 'title', 'body'],
|
|
55
|
+
base: {
|
|
56
|
+
root: { rounded: 'lg', borderWidth: '1px', p: '4' },
|
|
57
|
+
title: { fontWeight: 'semibold', mb: '2' },
|
|
58
|
+
body: { color: 'text.muted' },
|
|
59
|
+
},
|
|
60
|
+
variants: {
|
|
61
|
+
size: {
|
|
62
|
+
sm: { root: { p: '3' }, title: { fontSize: 'sm' } },
|
|
63
|
+
md: { root: { p: '4' }, title: { fontSize: 'md' } },
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
defaultVariants: { size: 'md' },
|
|
67
|
+
});
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### vanilla-extract
|
|
71
|
+
|
|
72
|
+
Styles live in `*.css.ts` files compiled to static `.css` bundles with locally scoped class names and CSS variables.
|
|
73
|
+
|
|
74
|
+
- **Code-split themes**: define a contract with `createThemeContract({ ...null })` and implement separate bundles with `createTheme(vars, values)`.
|
|
75
|
+
- **Component variants**: use `@vanilla-extract/recipes` (`recipe` + `RecipeVariants<typeof button>`) for typed variant matrices.
|
|
76
|
+
- **Atomic utilities**: use `@vanilla-extract/sprinkles` (`defineProperties` + `createSprinkles`). Always assign each `defineProperties(...)` call to a variable before passing it into `createSprinkles(...)`—inlining breaks TypeScript inference.
|
|
77
|
+
- **Runtime dynamic values**: use `assignInlineVars` from `@vanilla-extract/dynamic` to bind runtime props to typed CSS custom properties.
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
// theme.css.ts
|
|
81
|
+
import { createThemeContract, createTheme, style } from '@vanilla-extract/css';
|
|
82
|
+
import { recipe, type RecipeVariants } from '@vanilla-extract/recipes';
|
|
83
|
+
|
|
84
|
+
export const vars = createThemeContract({
|
|
85
|
+
color: { brand: null, surface: null },
|
|
86
|
+
font: { body: null },
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
export const lightTheme = createTheme(vars, {
|
|
90
|
+
color: { brand: '#0f4c81', surface: '#ffffff' },
|
|
91
|
+
font: { body: 'system-ui, sans-serif' },
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
export const container = style({
|
|
95
|
+
background: vars.color.surface,
|
|
96
|
+
fontFamily: vars.font.body,
|
|
97
|
+
paddingInline: '1rem',
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
export const button = recipe({
|
|
101
|
+
base: { fontFamily: vars.font.body, borderRadius: '6px' },
|
|
102
|
+
variants: {
|
|
103
|
+
tone: {
|
|
104
|
+
brand: { background: vars.color.brand, color: '#ffffff' },
|
|
105
|
+
surface: { background: vars.color.surface, color: vars.color.brand },
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
export type ButtonVariants = RecipeVariants<typeof button>;
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
```tsx
|
|
114
|
+
import { assignInlineVars } from '@vanilla-extract/dynamic';
|
|
115
|
+
import { container, vars } from './theme.css';
|
|
116
|
+
|
|
117
|
+
<section className={container} style={assignInlineVars(vars, { color: { brand, surface }, font: { body } })} />
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Pigment CSS & Linaria (WyW-in-JS)
|
|
121
|
+
|
|
122
|
+
- **Pigment CSS (`@pigment-css/react`)**: build-time CSS-in-JS (built on WyW-in-JS) designed as an RSC-compatible migration target for Emotion/MUI teams (`styled`, `css`, `variants`, theme CSS variables). Dynamic styles must use `variants` or CSS custom properties rather than arbitrary runtime functions.
|
|
123
|
+
- **Linaria (`@linaria/core`, `@linaria/react`, `@wyw-in-js/vite`)**: extracts tagged template literals to static CSS and compiles dynamic prop interpolations into CSS custom properties applied via inline `style`. Any custom component wrapped with `styled(CustomCard)` that uses dynamic interpolations **must accept and forward both `className` and `style`**; dropping `style` silently breaks dynamic variables.
|
|
124
|
+
|
|
125
|
+
## Atomic CSS compilers
|
|
126
|
+
|
|
127
|
+
### StyleX (`@stylexjs/stylex`)
|
|
128
|
+
|
|
129
|
+
StyleX compiles co-located JS style objects into collision-free atomic CSS where last-applied style always wins deterministically.
|
|
130
|
+
|
|
131
|
+
- **Strict variable file rule**: `stylex.defineVars()` and `stylex.defineConsts()` **must** live in `*.stylex.ts` / `*.stylex.js` files as **named exports only** (no default exports and no other exports in that file). Keys starting with `--` emit unhashed custom property names.
|
|
132
|
+
- **Theming & composition**: apply themes created with `stylex.createTheme(vars, overrides)` directly alongside style objects inside `stylex.props(darkTheme, styles.root, isCompact && styles.compact)`.
|
|
133
|
+
|
|
134
|
+
```ts
|
|
135
|
+
// tokens.stylex.ts (named exports only)
|
|
136
|
+
import * as stylex from '@stylexjs/stylex';
|
|
137
|
+
|
|
138
|
+
export const colors = stylex.defineVars({
|
|
139
|
+
text: '#111827',
|
|
140
|
+
surface: '#ffffff',
|
|
141
|
+
'--brand-accent': '#0f4c81',
|
|
142
|
+
});
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
```tsx
|
|
146
|
+
import * as stylex from '@stylexjs/stylex';
|
|
147
|
+
import { colors } from './tokens.stylex';
|
|
148
|
+
|
|
149
|
+
const darkTheme = stylex.createTheme(colors, {
|
|
150
|
+
text: '#f9fafb',
|
|
151
|
+
surface: '#0b0f14',
|
|
152
|
+
'--brand-accent': '#60a5fa',
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
const styles = stylex.create({
|
|
156
|
+
card: { backgroundColor: colors.surface, color: colors.text, padding: '16px' },
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
<article {...stylex.props(isDark && darkTheme, styles.card)} />
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Tamagui Web (`@tamagui/core` / `tamagui`)
|
|
163
|
+
|
|
164
|
+
Choose **Tamagui** when sharing styled primitives and design tokens across **React Web and React Native / Expo** (not for web-only projects where Tailwind v4, CSS Modules, or Panda CSS are simpler). Enable the build-time optimizing compiler (`@tamagui/vite-plugin` or `@tamagui/next-plugin`) so static style props flatten into atomic CSS classes and `<div>`/`<span>` tags instead of runtime style objects, and define tokens/themes centrally in `tamagui.config.ts`.
|
|
165
|
+
|
|
166
|
+
### UnoCSS
|
|
167
|
+
|
|
168
|
+
UnoCSS is an on-demand atomic CSS engine configured in `uno.config.ts`.
|
|
169
|
+
|
|
170
|
+
- Use `presetWind4()` for Tailwind v4-compatible utilities, `shortcuts` for repeated semantic patterns, and `@unocss/transformer-directives` when CSS `@apply` / directives are needed.
|
|
171
|
+
- Because UnoCSS extracts utilities statically, declare runtime-constructed class names in `safelist` (either static arrays or a `(context) => ...` function reading `context.theme`).
|
|
172
|
+
|
|
173
|
+
```ts
|
|
174
|
+
// uno.config.ts
|
|
175
|
+
import { defineConfig, presetWind4, transformerDirectives } from 'unocss';
|
|
176
|
+
|
|
177
|
+
export default defineConfig({
|
|
178
|
+
presets: [presetWind4()],
|
|
179
|
+
transformers: [transformerDirectives()],
|
|
180
|
+
shortcuts: {
|
|
181
|
+
'btn-primary': 'px-4 py-2 rounded-md font-medium bg-action text-on-action',
|
|
182
|
+
},
|
|
183
|
+
safelist: [
|
|
184
|
+
(ctx) => Object.keys(ctx.theme.colors || {}).map((c) => `bg-${c}-500`),
|
|
185
|
+
],
|
|
186
|
+
});
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## Component variant & recipe APIs
|
|
190
|
+
|
|
191
|
+
When styling with Tailwind, UnoCSS, or CSS Modules, manage multi-axis component variants with a typed variant builder instead of nested template-string conditionals.
|
|
192
|
+
|
|
193
|
+
| Tool | Best fit | Built-in `tailwind-merge` | Multi-slot support |
|
|
194
|
+
|---|---|---|---|
|
|
195
|
+
| CVA (`class-variance-authority` v0.7 / `cva` v1) | Single-element primitives, CSS Modules, Tailwind | Via `defineConfig` (v1) or wrapper `cn()` (v0.7) | No (compose separate `cva` calls) |
|
|
196
|
+
| Tailwind Variants (`tailwind-variants`) | Multi-part Tailwind components (cards, modals, inputs) | Yes (`twMerge: true` + `createTV`) | First-class `slots` and `compoundSlots` |
|
|
197
|
+
|
|
198
|
+
- **CVA conflict resolution**: plain `cva` concatenates class strings without resolving conflicting Tailwind utilities. In `cva` v1 (`cva` package), import `defineConfig` from **`'cva'`** and wire `twMerge` (use `tailwind-merge` v3+ with Tailwind v4); in `class-variance-authority` v0.7, wrap the output in `cn(buttonVariants(...), className)`.
|
|
199
|
+
|
|
200
|
+
```ts
|
|
201
|
+
// cva v1 (cva.config.ts)
|
|
202
|
+
import { defineConfig } from 'cva';
|
|
203
|
+
import { twMerge } from 'tailwind-merge';
|
|
204
|
+
|
|
205
|
+
export const { cva, cx: cn } = defineConfig({
|
|
206
|
+
hooks: {
|
|
207
|
+
onComplete: (className) => twMerge(className),
|
|
208
|
+
},
|
|
209
|
+
});
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
```ts
|
|
213
|
+
// tailwind-variants with custom token merge config + slots
|
|
214
|
+
import { createTV } from 'tailwind-variants';
|
|
215
|
+
|
|
216
|
+
export const tv = createTV({
|
|
217
|
+
twMergeConfig: {
|
|
218
|
+
extend: {
|
|
219
|
+
theme: { spacing: ['gap-grid'] },
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
export const card = tv({
|
|
225
|
+
slots: { base: 'rounded-xl p-4', header: 'font-semibold' },
|
|
226
|
+
variants: { elevated: { true: {}, false: {} } },
|
|
227
|
+
compoundSlots: [{ elevated: true, slots: ['base'], class: 'shadow-lg' }],
|
|
228
|
+
});
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
## CSS Modules, Lightning CSS, preprocessors, and token libraries
|
|
232
|
+
|
|
233
|
+
- **Lightning CSS + CSS Modules**: enable `css: { transformer: 'lightningcss' }` (and `build: { cssMinify: 'lightningcss' }`) in Vite for Rust-native CSS Modules, nesting, modern color/media-query lowering, vendor prefixing, and minification without a heavy PostCSS plugin chain:
|
|
234
|
+
|
|
235
|
+
```ts
|
|
236
|
+
// vite.config.ts
|
|
237
|
+
import { defineConfig } from 'vite';
|
|
238
|
+
|
|
239
|
+
export default defineConfig({
|
|
240
|
+
css: { transformer: 'lightningcss' },
|
|
241
|
+
build: { cssMinify: 'lightningcss' },
|
|
242
|
+
});
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
- **Sass / SCSS**: in existing SCSS codebases, use `@use` and `@forward` with explicit namespaces; do not add new legacy `@import` chains (deprecated in Dart Sass). Never use Sass `$variables` for runtime theme switching—emit CSS custom properties instead.
|
|
246
|
+
- **Open Props**: import only the packs you use (`@import "open-props/easings";`, `@import "open-props/sizes";`) or wire `postcss-jit-props` so unused custom properties are tree-shaken out of the production stylesheet.
|
|
247
|
+
- **Bootstrap / Bulma**: when maintaining apps built on them, override semantic Sass/CSS variables at the theme layer rather than fighting framework specificity with `!important` or layering Tailwind on top.
|
|
248
|
+
|
|
249
|
+
## Runtime CSS-in-JS (Emotion, styled-components)
|
|
250
|
+
|
|
251
|
+
- **RSC boundary**: Emotion and styled-components rely on React Context and runtime `<style>` insertion. They cannot execute inside React Server Components without `'use client'` boundaries and an SSR style registry (`useServerInsertedHTML` in Next.js App Router).
|
|
252
|
+
- **Decision rule**: keep runtime CSS-in-JS only when extending an existing Emotion/styled-components codebase or a component library that mandates it. For greenfield RSC/SSR apps, choose CSS Modules + Lightning CSS, Tailwind v4, Panda CSS, vanilla-extract, Pigment CSS, or StyleX.
|
|
253
|
+
|
|
254
|
+
## Do/don't pairs
|
|
255
|
+
|
|
256
|
+
| Do | Don't |
|
|
257
|
+
|---|---|
|
|
258
|
+
| Use literal tokens, `cva`/`sva`, or `staticCss` in Panda CSS | Pass `css({ color: \`red.${shade}\` })` or runtime spreads into Panda `css()` |
|
|
259
|
+
| Put `stylex.defineVars()` in `*.stylex.ts` as named exports only | Export components or default exports from a `*.stylex.ts` token file |
|
|
260
|
+
| Define `defineProperties()` variables before `createSprinkles()` | Inline `defineProperties()` calls inside `createSprinkles()` |
|
|
261
|
+
| Forward both `className` and `style` into Linaria `styled(Custom)` targets | Forward only `className` and silently drop dynamic CSS variables |
|
|
262
|
+
| Import `defineConfig` from `'cva'` (v1) and wire `twMerge` (v3 for Tailwind v4) | Import non-existent `'cva/config'` or concatenate conflicting Tailwind utilities |
|
|
263
|
+
| Enable `css: { transformer: 'lightningcss' }` in Vite for CSS Modules & native CSS | Add Sass + 6 PostCSS plugins solely for CSS nesting and autoprefixer |
|
|
264
|
+
| Use `postcss-jit-props` or selective `@import` packs with Open Props | Ship the entire unshaken Open Props bundle when using five tokens |
|
|
265
|
+
| Use Sass `@use`/`@forward` + CSS custom properties for runtime themes | Write new `@import` chains or bake dark mode into static Sass `$vars` |
|
|
266
|
+
|
|
267
|
+
## Verification commands
|
|
268
|
+
|
|
269
|
+
```sh
|
|
270
|
+
npm run build
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
Inspect the built `.css` output (`static`) to confirm zero-runtime classes and custom properties were actually emitted (catching Panda/UnoCSS/Tamagui extraction misses), and verify computed styles across light/dark themes and component variants in a real browser (`rendered`).
|
|
@@ -20,33 +20,83 @@ Load fonts in `app.html`/root layout or font tooling with explicit fallbacks/sub
|
|
|
20
20
|
|
|
21
21
|
## Motion/reduced motion
|
|
22
22
|
|
|
23
|
-
Svelte transitions (`transition
|
|
23
|
+
Svelte transitions (`transition:`, `in:`, `out:`, `animate:`) are concise but still need purpose. Read `prefersReducedMotion.current` from `svelte/motion` (SSR-safe reactive wrapper around `matchMedia('(prefers-reduced-motion: reduce)')`) to zero durations or swap spatial slides for subtle opacity fades; do not animate list reordering when it destroys orientation.
|
|
24
24
|
|
|
25
25
|
## Accessibility specifics
|
|
26
26
|
|
|
27
|
-
Use real elements. Svelte warnings help but do not guarantee usable UX. Manage focus after navigation/dialog/state removal, label form controls, and preserve keyboard behavior. `{@html}` is dangerous for untrusted content and
|
|
27
|
+
Use real elements. Svelte compiler a11y warnings help but do not guarantee usable UX. Use `$props.id()` (Svelte 5.20+) to generate SSR-safe unique IDs for `<label for>` and `aria-describedby` inside reusable components. Manage focus after navigation/dialog/state removal, label form controls, and preserve keyboard behavior. `{@html}` is dangerous for untrusted content and bypasses semantic/control guarantees.
|
|
28
28
|
|
|
29
29
|
## States idiom
|
|
30
30
|
|
|
31
|
-
SvelteKit `load` return shape, `error`, `status`, stores, and form action results each represent
|
|
31
|
+
SvelteKit `load` return shape, `error`, `status`, `$app/state` (`page`, `navigating`, `updated` — replacing legacy `$app/stores` in SvelteKit 2.12+), and form action results each represent distinct lifecycle states. Render loading/stale/empty/error explicitly. Progressive enhancement through `use:enhance` should preserve input, expose pending state, prevent duplicate submission, and handle rollback.
|
|
32
32
|
|
|
33
33
|
## Forms idiom
|
|
34
34
|
|
|
35
|
-
Svelte `bind:value` does not replace labels or validation timing. Native form actions plus `use:enhance` provide resilient baseline
|
|
35
|
+
Svelte `bind:value` does not replace labels or validation timing. Native `+page.server.ts` form actions (`export const actions = { ... } satisfies Actions`) returning `fail(400, { values, errors })` plus `use:enhance` (or SvelteKit Superforms for typed multi-field forms; see `forms-validation.md`) provide a resilient baseline. Use correct `autocomplete`/`inputmode` attributes and preserve invalid input returned by server actions.
|
|
36
|
+
|
|
37
|
+
## Svelte 5 Runes, Attachments, and SvelteKit 2 idioms
|
|
38
|
+
|
|
39
|
+
- **Runes & Snippets**: use `$state`, `$derived` / `$derived.by`, `$effect`, `$props`, `$bindable`, and `{#snippet}` / `{@render children?.()}` instead of legacy `export let`, `$:`, and `<slot>`. Use standard DOM event attributes (`onclick={...}`, `onkeydown={...}`) rather than deprecated `on:click`.
|
|
40
|
+
- **Derived vs Effect**: compute derived values with `$derived(...)`—never `$effect(() => { derived = ... })`, which introduces extra render passes and feedback loops. Use `$effect` only for external DOM/observer/network synchronization with a cleanup return.
|
|
41
|
+
- **Performance & serialization**: use `$state.raw(...)` for large immutable arrays/objects (tables, GeoJSON, charts) that do not need deep proxy overhead, and `$state.snapshot(state)` before passing reactive state to `structuredClone`, Web Workers, `localStorage`, or third-party non-Svelte libraries.
|
|
42
|
+
- **Reactive collections & media**: use `svelte/reactivity` (`SvelteMap`, `SvelteSet`, `SvelteURLSearchParams`, `MediaQuery`) and `svelte/motion` (`prefersReducedMotion`) instead of manual store wrappers.
|
|
43
|
+
- **Attachments (`{@attach ...}`)**: in Svelte 5.29+, prefer `{@attach tooltip(opts)}` attachments over legacy `use:` actions—attachments run reactively inside an effect, return a cleanup function, and can be passed through component props via `createAttachmentKey()`.
|
|
44
|
+
- **SSR isolation for `.svelte.ts` modules**: create rune-backed state classes in `.svelte.ts`, instantiate them inside the root layout, and expose them via `setContext` / `getContext`—never export mutable module-level `$state` singletons in SvelteKit SSR, or user data will leak across concurrent requests.
|
|
45
|
+
|
|
46
|
+
```svelte
|
|
47
|
+
<script lang="ts">
|
|
48
|
+
import { page } from '$app/state';
|
|
49
|
+
import { prefersReducedMotion } from 'svelte/motion';
|
|
50
|
+
import { MediaQuery } from 'svelte/reactivity';
|
|
51
|
+
import type { Snippet } from 'svelte';
|
|
52
|
+
import type { Attachment } from 'svelte/attachments';
|
|
53
|
+
|
|
54
|
+
let { value = $bindable(''), children }: { value?: string; children?: Snippet } = $props();
|
|
55
|
+
const fieldId = $props.id();
|
|
56
|
+
const isCompact = new MediaQuery('(max-width: 40rem)');
|
|
57
|
+
let trimmedLength = $derived(value.trim().length);
|
|
58
|
+
|
|
59
|
+
const focusOnMount: Attachment<HTMLInputElement> = (node) => {
|
|
60
|
+
if (!prefersReducedMotion.current) node.dataset.animated = 'true';
|
|
61
|
+
return () => { delete node.dataset.animated; };
|
|
62
|
+
};
|
|
63
|
+
</script>
|
|
64
|
+
|
|
65
|
+
<label for={fieldId}>Search ({page.url.pathname})</label>
|
|
66
|
+
<input id={fieldId} bind:value {@attach focusOnMount} data-compact={isCompact.current} />
|
|
67
|
+
{@render children?.()}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
// src/routes/invoices/+page.server.ts
|
|
72
|
+
import { fail } from '@sveltejs/kit';
|
|
73
|
+
import type { Actions } from './$types';
|
|
74
|
+
|
|
75
|
+
export const actions = {
|
|
76
|
+
create: async ({ request, locals }) => {
|
|
77
|
+
if (!locals.user) return fail(401, { message: 'Sign in required.' });
|
|
78
|
+
const data = await request.formData();
|
|
79
|
+
const batch = String(data.get('batch') ?? '').trim();
|
|
80
|
+
if (!batch) return fail(400, { batch, error: 'Batch code is required.' });
|
|
81
|
+
return { ok: true };
|
|
82
|
+
}
|
|
83
|
+
} satisfies Actions;
|
|
84
|
+
```
|
|
36
85
|
|
|
37
86
|
## Do/don't pairs
|
|
38
87
|
|
|
39
88
|
| Do | Don't |
|
|
40
89
|
|---|---|
|
|
41
|
-
| `<a href="/invoice/42">View invoice</a>` | `<div
|
|
42
|
-
|
|
|
43
|
-
|
|
|
44
|
-
|
|
|
45
|
-
|
|
|
90
|
+
| `<a href="/invoice/42">View invoice</a>` | `<div onclick={() => goto('/invoice/42')}>View invoice</div>` (or deprecated `on:click`) |
|
|
91
|
+
| `export const actions = { create: async (...) => fail(400, { ... }) } satisfies Actions` | `export function actions(...)` (invalid SvelteKit export) or throwing raw 500s for validation |
|
|
92
|
+
| Instantiate `.svelte.ts` state per layout and share via `setContext`/`getContext` | Export mutable module-level `$state` in SvelteKit SSR (cross-request data leak) |
|
|
93
|
+
| Import `page`, `navigating`, `updated` from `$app/state` | Keep importing legacy `$app/stores` in new SvelteKit 2 code |
|
|
94
|
+
| `$props.id()` for `<label for>` + `aria-describedby` and `$state.snapshot()` for workers/APIs | Duplicate static IDs or passing raw `$state` proxies into `postMessage`/`structuredClone` |
|
|
95
|
+
| Stable keyed `{#each items as item (item.id)}` | Keyless list mutation causing focus/state reuse bugs |
|
|
46
96
|
|
|
47
97
|
## Known traps
|
|
48
98
|
|
|
49
|
-
SSR
|
|
99
|
+
Cross-request SSR leaks from module-level `$state` in `.svelte.ts`, writing `export function actions` instead of `export const actions = { ... }`, deep-proxying large datasets without `$state.raw`, passing `$state` proxies to `structuredClone` without `$state.snapshot`, mixing legacy `on:`/`$:`/`$app/stores` with Svelte 5 runes, keyed each-block focus reuse, treating compiler a11y warnings as full WCAG coverage.
|
|
50
100
|
|
|
51
101
|
## Verification commands
|
|
52
102
|
|
|
@@ -58,4 +108,4 @@ npm run build
|
|
|
58
108
|
npx playwright test
|
|
59
109
|
```
|
|
60
110
|
|
|
61
|
-
Use browser inspection for rendering/hydration evidence; `check` is static evidence only.
|
|
111
|
+
Use browser inspection for rendering/hydration evidence (`rendered`); `svelte-check` is `static` evidence only.
|
|
@@ -6,31 +6,56 @@ Tailwind is an implementation layer, not the design direction. Treat utility cla
|
|
|
6
6
|
|
|
7
7
|
These examples target v4. If the existing project uses v3, preserve its configuration and content discovery unless migration is in scope; verify the installed major before copying CSS directives.
|
|
8
8
|
|
|
9
|
-
Tailwind v4 is CSS-first.
|
|
9
|
+
Tailwind v4 is CSS-first. On Vite projects, use the native `@tailwindcss/vite` plugin instead of the PostCSS wrapper for faster builds. When mapping semantic CSS custom properties into Tailwind theme tokens, use **`@theme inline`**—not plain `@theme`—so utilities emit `var(--semantic-color-action)` directly at the element instead of binding an intermediate variable on `:root` that breaks scoped theme/mode overrides (such as `[data-theme="dark"]` or `.surface-inverted`):
|
|
10
10
|
|
|
11
11
|
```css
|
|
12
12
|
@import "tailwindcss";
|
|
13
13
|
@import "./tokens.css";
|
|
14
|
+
@import "tw-animate-css";
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
/* Scan external UI packages or monorepo paths outside auto-detected git-tracked sources */
|
|
17
|
+
@source "../packages/ui/src";
|
|
18
|
+
|
|
19
|
+
/* Class/attribute dark-mode selector when not using prefers-color-scheme only */
|
|
20
|
+
@custom-variant dark (&:where([data-theme="dark"], [data-theme="dark"] *));
|
|
21
|
+
|
|
22
|
+
@theme inline {
|
|
16
23
|
--color-action: var(--semantic-color-action);
|
|
17
24
|
--color-surface: var(--semantic-color-background);
|
|
25
|
+
--color-ink: var(--semantic-color-foreground);
|
|
26
|
+
--font-sans: var(--semantic-font-body);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* Reusable semantic utilities participate in variants (hover:, md:, dark:) */
|
|
30
|
+
@utility prose-measure {
|
|
31
|
+
max-inline-size: 68ch;
|
|
32
|
+
text-wrap: pretty;
|
|
18
33
|
}
|
|
19
34
|
```
|
|
20
35
|
|
|
21
|
-
Do not redefine a parallel raw palette in `@theme` when semantic variables already exist. Use
|
|
36
|
+
Do not redefine a parallel raw palette in `@theme` when semantic variables already exist. Use `@theme` (without `inline`) only for static literal values you intend to resolve at `:root`.
|
|
37
|
+
|
|
38
|
+
## v4 breaking defaults & ecosystem compatibility
|
|
39
|
+
|
|
40
|
+
Check these v4 changes whenever porting patterns or mixing older snippets:
|
|
41
|
+
|
|
42
|
+
- **Default `border-color` is `currentColor`** (was `gray-200` in v3) — always specify an explicit semantic border color (`border-subtle` / `border-line`) on `border`.
|
|
43
|
+
- **Default `ring` width is `1px` and `currentColor`** (was `3px` blue in v3) — use `ring-2 ring-action` explicitly when a thicker focus ring is intended.
|
|
44
|
+
- **`outline-hidden` replaces v3 `outline-none`** — `outline-hidden` keeps a transparent outline visible in Windows Forced Colors Mode; `outline-none` now sets `outline-style: none` and hides focus in forced colors.
|
|
45
|
+
- **Built-in container queries**: `@container`, `@container/sidebar`, `@md:`, `@max-sm:` work natively in v4 without `@tailwindcss/container-queries`.
|
|
46
|
+
- **Companion packages**: upgrade to `tailwind-merge` v3+ for v4 class deduplication, and use `tw-animate-css` instead of the deprecated v3 `tailwindcss-animate` JS plugin.
|
|
22
47
|
|
|
23
48
|
## Layout and responsive idioms
|
|
24
49
|
|
|
25
|
-
Use grid/flex utilities to express actual composition. Responsive prefixes (`sm:`, `md:`…) should implement restructuring decisions, not hide the absence of one. Prefer logical utilities (`ms-`, `me-`, `ps-`, `pe-`, `start-`, `end-`) when available. Extract repeated semantic patterns only when reuse is real; premature component abstraction can be worse than legible utilities.
|
|
50
|
+
Use grid/flex utilities and built-in `@container` queries (`@container` parent + `@md:grid-cols-[10rem_1fr]`) to express actual composition. Responsive prefixes (`sm:`, `md:`…) should implement restructuring decisions, not hide the absence of one. Prefer logical utilities (`ms-`, `me-`, `ps-`, `pe-`, `start-`, `end-`) when available. Extract repeated semantic patterns only when reuse is real; premature component abstraction can be worse than legible utilities.
|
|
26
51
|
|
|
27
52
|
## Typography/custom fonts
|
|
28
53
|
|
|
29
|
-
Define font families/size/line-height roles in `@theme` or CSS. Avoid arbitrary values for every text size. Use measure utilities
|
|
54
|
+
Define font families/size/line-height roles in `@theme inline` or CSS. Avoid arbitrary values for every text size. Use measure utilities (`max-w-prose` or a custom `@utility`) deliberately and preserve fallback/subset behavior.
|
|
30
55
|
|
|
31
56
|
## Motion/reduced motion
|
|
32
57
|
|
|
33
|
-
Use Tailwind motion utilities only for purposeful properties; never `transition-all`. Tailwind provides motion-safe
|
|
58
|
+
Use Tailwind motion utilities only for purposeful properties; never `transition-all`. Tailwind provides `motion-safe:` and `motion-reduce:` variants—use them to supply meaningful alternatives:
|
|
34
59
|
|
|
35
60
|
```html
|
|
36
61
|
<div class="transition-opacity motion-reduce:transition-none">
|
|
@@ -38,11 +63,11 @@ Use Tailwind motion utilities only for purposeful properties; never `transition-
|
|
|
38
63
|
|
|
39
64
|
## Accessibility specifics
|
|
40
65
|
|
|
41
|
-
Tailwind does not create semantics. Use real HTML controls, visible `focus-visible` styles, screen-reader utility only for content that truly should be visually hidden, and adequate contrast. Do not use `sr-only` to hide labels that sighted users also need.
|
|
66
|
+
Tailwind does not create semantics. Use real HTML controls, visible `focus-visible` styles, `outline-hidden` (never bare `outline-none` without a forced-colors-safe replacement), screen-reader utility only for content that truly should be visually hidden, and adequate contrast. Do not use `sr-only` to hide labels that sighted users also need.
|
|
42
67
|
|
|
43
68
|
## States idiom
|
|
44
69
|
|
|
45
|
-
Use state variants intentionally: `hover:`, `focus-visible:`, `active:`, `disabled:`, `aria-*`, `data-*`, dark
|
|
70
|
+
Use state variants intentionally: `hover:`, `focus-visible:`, `active:`, `disabled:`, `aria-*`, `data-*`, `dark:`, `forced-colors:`. Every interactive element still needs loading/error/empty/disabled semantics beyond styling.
|
|
46
71
|
|
|
47
72
|
## Forms idiom
|
|
48
73
|
|
|
@@ -52,15 +77,16 @@ Utilities can accelerate layout but must not replace labels/input attributes. Pr
|
|
|
52
77
|
|
|
53
78
|
| Do | Don't |
|
|
54
79
|
|---|---|
|
|
55
|
-
|
|
|
80
|
+
| `@theme inline { --color-surface: var(--semantic-color-background); }` | Plain `@theme` referencing `var(--...)` that freezes theme resolution at `:root` |
|
|
81
|
+
| `class="focus-visible:outline-2 focus-visible:outline-offset-2"` or `outline-hidden focus-visible:ring-2` | `class="outline-none"` (breaks Windows Forced Colors visibility in v4) |
|
|
82
|
+
| `class="border border-line"` with explicit semantic border color | Bare `class="border"` assuming v3's `gray-200` default |
|
|
56
83
|
| `class="transition-opacity motion-reduce:transition-none"` | `class="transition-all duration-500"` on everything |
|
|
57
|
-
|
|
|
58
|
-
| `
|
|
59
|
-
| intentional responsive restructuring `grid md:grid-cols-[2fr_1fr]` | stacking centered cards because mobile was never designed |
|
|
84
|
+
| `ms-4`/`pe-2` and built-in `@container` (`@md:flex-row`) | physical `ml-4`/`pr-2` by reflex or installing obsolete `@tailwindcss/container-queries` |
|
|
85
|
+
| `tailwind-merge` v3 + `tw-animate-css` + `@tailwindcss/vite` | Mixing `tailwind-merge` v2 or `tailwindcss-animate` into a v4 build |
|
|
60
86
|
|
|
61
87
|
## Known traps
|
|
62
88
|
|
|
63
|
-
|
|
89
|
+
Plain `@theme` freezing CSS variable aliases at `:root`, uncolored v4 `border` inheriting `currentColor`, `outline-none` erasing forced-colors focus indicators, missing `@source` for workspace UI packages, utility verbosity hiding architecture, arbitrary-value sprawl, dark-mode inversion, visual sameness mistaken for system consistency.
|
|
64
90
|
|
|
65
91
|
## Verification commands
|
|
66
92
|
|
|
@@ -70,4 +96,4 @@ npm run build
|
|
|
70
96
|
npx playwright test
|
|
71
97
|
```
|
|
72
98
|
|
|
73
|
-
Inspect computed CSS/
|
|
99
|
+
Inspect computed CSS and dark/scoped theme switching in a real browser (`rendered`); utility presence alone is only `static` evidence.
|