跳至正文Skip to content

深色模式Dark ModeDark Mode深色模式

一键切换深浅两套配色:跟随系统 + 手动切换,vibe coder 问 AI 最多的问题之一。Dark mode toggles two palettes in one tap—follows system plus manual switch, one of the most-asked AI questions.

← 返回首页定位← View in Catalog

实时交互演示Live Interactive Demo

可直接点击、悬停或滚动体验Click, hover, or scroll to test live
深色模式演示卡片

这样说Say This一句话描述需求Plain-Language Phrasing

整站加深色模式:右上角按钮切换,记住用户选择,默认跟随系统。Dark mode for the whole site: toggle button (top right), persists the choice, follows the system by default.

完整 AI PromptComplete AI Prompts

标准版(直接实现核心交互与样式)Standard Prompt (Core layout & behavior)
Dark mode for the whole site: toggle button (top right), persists the choice, follows the system by default.
动效增强版(含过渡节奏与微交互细节)Animated Prompt (With transitions & motion feel)
Dark mode toggle with 300ms smooth theme crossfade via CSS variables, persisted to localStorage, respects prefers-color-scheme.

设计规范条目Spec Entry

把这条技巧写进 AI 编程设计规范(DESIGN_SPEC.md / CLAUDE.md / .cursorrules)时的条目预览:核心规则、DO / DON'T 与 Prompt 全部逐字来自本技巧数据,原文未声明显式禁区时不列 DON'T。点「+ 加入规范」可与其它技巧合并成完整规范包一键导出。A preview of this technique as an entry in an AI coding design spec (DESIGN_SPEC.md / CLAUDE.md / .cursorrules): the core rule, DO / DON'T, and prompts are quoted verbatim from this technique’s data, and DON'T appears only where the source states one. Click “+ Add to Spec” to merge it with other techniques into a full pack.

### 1. 深色模式(Dark Mode) `#darkmode`
- 分类:内容展示(Content Display)
- 核心规则:一键切换深浅两套配色:跟随系统 + 手动切换,vibe coder 问 AI 最多的问题之一。
- 可以这样说:整站加深色模式:右上角按钮切换,记住用户选择,默认跟随系统。
- DO(逐字来自标准版 Prompt):
  - Dark mode for the whole site: toggle button (top right), persists the choice, follows the system by default
- 标准版 Prompt:
  > Dark mode for the whole site: toggle button (top right), persists the choice, follows the system by default.
- 动效版 Prompt:
  > Dark mode toggle with 300ms smooth theme crossfade via CSS variables, persisted to localStorage, respects prefers-color-scheme.
- 常见叫法:暗黑 / 夜间模式 / 主题切换 / dark mode / 护眼
- 详情与实时演示:https://design.knowhy.net/techniques/darkmode/
### 1. Dark Mode (深色模式) `#darkmode`
- Category: Content Display
- Core rule: Dark mode toggles two palettes in one tap—follows system plus manual switch, one of the most-asked AI questions.
- DO (verbatim from the standard prompt): 
  - Dark mode for the whole site: toggle button (top right), persists the choice, follows the system by default
- Standard prompt: 
  > Dark mode for the whole site: toggle button (top right), persists the choice, follows the system by default.
- Animated prompt: 
  > Dark mode toggle with 300ms smooth theme crossfade via CSS variables, persisted to localStorage, respects prefers-color-scheme.
- Also known as: 暗黑 / 夜间模式 / 主题切换 / dark mode / 护眼
- Detail & live demo: https://design.knowhy.net/techniques/darkmode/

适用场景与提示词要点When to Use & Prompt Tips

  • 展示指标数据、定价方案、时间线、评价背书或高频浏览的信息流时Presenting KPIs, pricing tiers, timelines, testimonials, or dense content feeds
  • 让 AI 控制单卡信息密度、数字等宽对齐(tabular-nums)与主次对比Ask AI for tabular-nums alignment, balanced card density, and clear visual hierarchy
  • 统一卡片边框、圆角与留白节奏,信息多也不显杂乱Consistent borders, radii, and spacing keep content-heavy views calm and scannable
常见大白话叫法:Everyday search cues:

规范打包 · Prompt PackSpec Pack · Prompt Pack

把已选的真实技巧汇总成可直接粘贴给 Claude / Codex / Cursor / Antigravity 的设计约束文档。Bundle the selected techniques into a design-constraint document ready to paste into Claude / Codex / Cursor / Antigravity.

目标格式Target format
技术栈提示Stack hint
文档语言Document language

已选技巧Selected0 / 20

还没有选择技巧:关闭面板后在技巧卡片或详情页点「+ 加入规范」。Nothing selected yet: close this panel and click “+ Add to Spec” on any card or detail page.

    场景 Starter PacksStarter Packs

    4 套高频实战预设,全部由本站真实技巧组成;一键载入会与当前规范包合并,载入后可直接微调导出。Four battle-tested presets built only from real techniques on this site. Loading merges into the current pack, ready to tweak and export.