Nextjs Multi Design System 标志

Nextjs Multi Design System

社区
MiladJoodi
nextjs-multi-design-system

在 Next.js 应用中构建并调试多个彼此隔离的设计系统:style-* body 类、Cookie/localStorage 同步、防止 FOUC、明暗主题共存、SSR/水合、iframe 组件预览、父级与 iframe 之间的主题同步,以及设计 Token。切换主题时错误样式闪现、iframe 预览未响应选择器,或文档与预览不一致时使用。

概览

发布者MiladJoodi
代码仓库skills
技能名称nextjs-multi-design-system
星标数
24
复刻数
1
附带文件
仅含指令
许可协议MIT
链接
  • Markdown 格式的指令

    模型按需加载 SKILL.md 文件,因此只有在请求确实与该技能匹配时才会消耗 Token。

  • 兼容任何大语言模型

    AI 技能采用纯 Markdown,而非特定提供商的代码,因此可搭配 GPT、Claude、Gemini、Grok 或本地模型使用。

  • 指令自成一体

    模型所需的一切都包含在指令中,无需同步额外文件。

  • 开源

    由 MiladJoodi 发布于 GitHub。请在安装前查看技能的源文件。

安装

在 TypingMind 中安装 Nextjs Multi Design System AI 技能,即可搭配任意大语言模型使用;也可以将其放入其他支持读取 SKILL.md 的智能体中。

1

安装到 TypingMind

TypingMind 可直接从 GitHub 文件夹安装技能:读取 SKILL.md,打包资源文件,并将结果保存在本地。

  1. 打开应用,前往“插件 → 技能”。
  2. 选择“从 GitHub 安装”。
  3. 粘贴下方的技能文件夹 URL 并确认。
    https://github.com/MiladJoodi/skills/tree/main/skills/nextjs-multi-design-system
  4. 请在每个需要使用该技能的聊天中启用它。
依次选择“插件 → 技能 → 添加技能 → 从 GitHub URL 导入”,然后粘贴文件夹 URL 并点击“继续”。
2

安装到其他智能体

任何支持 Agent Skills 格式的智能体都可以使用此技能,只需将文件夹复制到该智能体的技能目录中。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/MiladJoodi/skills.git /tmp/skills
mkdir -p .claude/skills
cp -r /tmp/skills/skills/nextjs-multi-design-system .claude/skills/nextjs-multi-design-system
复制后,请重启 Claude Code,以加载新技能。

在 TypingMind 中使用此技能

在任意 TypingMind 聊天中启用 Nextjs Multi Design System,后续即可交由模型处理。技能的名称和描述会放在系统提示词中,一旦请求匹配,模型就会自动加载完整指令,无需您手动调用,且在实际使用前不会消耗 Token。

一旦请求与技能匹配,模型就会自动加载 Nextjs Multi Design System。

兼容任何 AI 模型

AI 技能是纯 Markdown 指令,而非特定提供商的代码,因此 Nextjs Multi Design System 不局限于最初适配的模型。只需在 TypingMind 中安装一次,即可搭配 GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 或您自行运行的本地模型使用,全程使用您自己的 API 密钥。

  • 仅在需要时加载

    系统提示词中仅包含技能名称和描述。首次遇到匹配的请求时才会加载完整指令,因此技能未使用时,这些指令不会消耗 Token。

  • 在聊天中切换模型

    技能是指令而非代码,因此切换模型不会导致技能失效,新模型会读取同一个 SKILL.md。

技能指令

这是模型会加载的 SKILL.md 内容。请在安装前阅读,因为技能就是模型将遵循的指令。

Next.js Multi Design System

Practical workflow for apps that ship more than one Design System / visual style in a single Next.js surface (docs, marketing, component showcase).

This is not a basic light/dark theme toggle guide. It covers isolation of multiple style systems (style-*), persistence across SSR, and preview iframes that must match the parent picker.

Scope

In scopeMulti DS switching, tokens, FOUC, cookie/SSR, iframe preview sync, docs↔preview parity
Out of scopeSingle-theme apps, generic CSS architecture, unrelated component APIs

When to use

  • One Next.js app hosts several named Design Systems (e.g. Nova, Vega, Glass).
  • Users switch DS without full reload and must not see the wrong tokens flash.
  • Component / block previews render in an iframe and must follow the parent.
  • Light/dark mode must coexist with a DS that has its own default appearance.

Architecture (what usually works)

1) One active style class on a root element

Map each Design System id → a single CSS scope class on body (or a dedicated root):

text
default  → style-nova
comfort  → style-vega
glass    → style-glass
…

Tokens and variant utilities hang off that class (Tailwind @custom-variant / .style-*:… selectors). Only one style-* class should be active.

2) Persist for SSR

  • Cookie (readable on the server) + localStorage (client restore).
  • Root layout reads cookie (or a proxy-forwarded header) and applies the matching style-* class in the first HTML.
  • A blocking inline script as the first child of body re-syncs localStorage → cookie → body.classList before paint (FOUC guard).

Do not wait for React hydration to apply the style class.

3) Light / dark is orthogonal

  • Theme mode (light / dark / system) lives on html (or next-themes).
  • Design System lives on body as style-*.
  • Some DS may default to dark when selected — stash the previous mode so the user can restore light without fighting the DS.

4) Preview = separate document

Iframe previews are a new document. They do not inherit React context.

Reliable patterns:

  • Put the active style in the iframe URL: /view/{styleName}/{item}?embed=1
  • Remount iframe when style changes (key={styleName})
  • Optionally pass style via query/cookie that the view route reads on SSR
  • Do not assume postMessage alone is enough for first paint

Agent workflow

Inspect

  • Find DS ids, cookie name, storage key, style class map.
  • Check root layout: SSR class on body / html.
  • Find bootstrap script (must run before first paint).
  • Find preview surfaces: iframe src, key, embed routes.
  • Note Turbopack/Webpack quirks if CSS for a DS is lazily imported.

Diagnose

SymptomLikely cause
Flash of wrong DS on loadCookie missing; bootstrap script after paint; SSR class wrong
Picker updates parent but not iframeIframe URL/key not tied to active style
Hydration mismatch warningServer cookie ≠ client localStorage on first render
Tokens look mixedTwo style-* classes, or scoped CSS not loaded for that DS
Dark DS + light mode fightMode not stashed/restored when selecting dark-default DS
Docs page ≠ previewPreview route uses different style source than docs shell

Plan

Emit a short brief before edits:

markdown
## Pre-change brief
**Root cause:** …
**Evidence:** …
**Proposed fix:** …
**Files affected:** …

Implement (minimal)

  1. Single source of truth for id → style-* map.
  2. Cookie + localStorage write on change; SSR read in layout.
  3. Blocking bootstrap on body that strips other style-* then adds active.
  4. Iframe src + key include active style name.
  5. Ensure CSS for every DS is available where the preview document renders (eager ship for picker CSS beats lazy chunks that arrive after FOUC).

Verify

  • Hard reload: first paint already has correct style-*.
  • Switch DS: parent and iframe match without full app reload.
  • Toggle light/dark after selecting a dark-default DS.
  • View page source / disable JS briefly: SSR class still correct from cookie.
  • Compare a docs example and the same item in preview side-by-side.

Component preview (included here)

Do not invent a separate skill for iframe preview when the hard part is multi-DS sync. Preview checklist:

  • Isolation: preview document loads its own CSS + style-*.
  • Responsive: viewport width controlled by parent chrome, not by shrinking the whole app shell incorrectly.
  • Embed mode: hide site chrome (?embed=1) so docs chrome ≠ preview chrome.
  • Parity: same registry item, same style name, same tokens as the docs claim.

Common failures

  • Applying DS only in a client provider → FOUC.
  • Putting style-* on a nested wrapper while tokens expect body.
  • Lazy-importing DS CSS that is not present on the iframe route.
  • Syncing via React context into an iframe (impossible across documents).
  • Forcing dark on every boot for a DS that should respect user mode after first selection.
  • Turbopack HMR leaving stale CSS modules after renaming a style id.

Best practices

  • Keep the id ↔ class map in one module shared by layout, picker, and bootstrap.
  • Prefer cookie for SSR; localStorage as client preference mirror.
  • Remount iframes on style change; do not mutate iframe DOM from parent.
  • Treat preview routes as first-class pages with the same token CSS.
  • Document which DS are dark-default and how mode restore works.

Report

markdown
## Multi-DS report
**Symptom:** …
**Root cause:** …
**Fix:** …
**SSR / FOUC:** pass | fail
**Iframe sync:** pass | fail
**Light/dark coexistence:** pass | fail

常见问题

Nextjs Multi Design System AI 技能有什么作用?

在 Next.js 应用中构建并调试多个彼此隔离的设计系统:style-* body 类、Cookie/localStorage 同步、防止 FOUC、明暗主题共存、SSR/水合、iframe 组件预览、父级与 iframe 之间的主题同步,以及设计 Token。切换主题时错误样式闪现、iframe 预览未响应选择器,或文档与预览不一致时使用。

为什么在 TypingMind 中使用 Nextjs Multi Design System?

因为您只需安装一次,就能搭配任何模型使用。Nextjs Multi Design System 采用纯 Markdown 格式,而非特定提供商专用的代码,因此同一技能可用于 GPT-5、Claude、Gemini、Grok 或本地模型。您甚至可以在聊天中途切换模型,而不会影响技能的正常使用。TypingMind 使用您自己的 API 密钥,因此您直接向提供商付费,而不是按席位订阅;您的技能和聊天记录也都保留在您自己的存储空间中。

如何在 TypingMind 中安装 Nextjs Multi Design System?

在 TypingMind 中打开“插件 → 技能 → 从 GitHub 安装”,然后粘贴 https://github.com/MiladJoodi/skills/tree/main/skills/nextjs-multi-design-system。TypingMind 会读取其中的 SKILL.md,并将其安装为技能,供您在各个聊天中按需启用。

哪些 AI 模型可以使用 Nextjs Multi Design System?

您在 TypingMind 中连接的任何模型都可以。AI 技能采用纯 Markdown 指令,而非特定提供商专用的代码,因此 GPT、Claude、Gemini、Grok 和本地模型都能在请求匹配时加载此技能。

Nextjs Multi Design System 可以搭配多少个 AI 模型使用?

数量不限。只要模型支持技能,您就可以将它与 Nextjs Multi Design System 搭配使用。GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 等模型都可以通过您自己的 API 密钥接入 TypingMind。

Nextjs Multi Design System AI 技能免费吗?

是的。MiladJoodi 已在 GitHub 上根据 MIT 许可证发布了该技能。您只需向自己的 AI 提供商支付所用 Token 的费用。

什么是 AI 技能?

AI 技能是一组可复用的指令,用于教会 AI 模型完成某项特定任务。它遵循开放的 Agent Skills 格式:包含名称和描述的 SKILL.md 文件,以及模型可能需要的脚本、模板或参考文件。模型仅在您的请求与技能匹配时才会读取这些指令,因此已安装的技能在使用前不会产生任何费用。

AI 技能与插件或 MCP 服务器有何不同?

插件或 MCP 服务器为模型提供可调用的新工具,也就是在某处运行并返回结果的代码。AI 技能则为模型提供知识和流程:如何处理任务、遵循哪些步骤,以及怎样的输出才算优质。技能采用纯 Markdown 格式,因此不需要服务器、API 密钥或运行时环境,并且适用于任何模型。

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇