Communitygithub.com

优化界面细节体验

应用具体的设计工程细节,使界面感觉更精致。适用于审查或改进UI间距、排版、边框、阴影、动效、点击区域、图标、文本换行和交互状态。

优化界面细节体验 是什么?

该技能旨在通过一系列具体的设计工程细节,提升用户界面的精致感和专业度。它源自社区贡献者 `linus707` 的 PR #1659,汇集了在实际项目中验证过的实用原则。技能涵盖了从底层样式(如字体平滑、图像轮廓)到高级交互(如嵌套圆角、光学对齐、CSS动效)的多个方面,并提供了具体的代码示例和最佳实践。它适用于各种 UI 组件的构建和审查,包括卡片、按钮、列表、表单和工具栏等。使用时,AI 代理可以根据提供的原则(如同心圆角、文本换行控制)生成具体的修改建议,并以“前后对比”表格的形式输出审查结果,确保改进的可追溯性和明确性。此技能兼容所有主流前端开发平台和 AI 编码代理。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/affaan-m/everything-claude-code/tree/main/skills/make-interfaces-feel-better

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

优化界面细节体验 是做什么的?

使用此技能来处理那些积累起来能让界面更精致的小型设计工程细节。

来源:从社区过时的 PR #1659 中抢救而来,作者 linus707。

何时使用

  • 用户觉得 UI 感觉不对劲、平淡、千篇一律、拥挤、跳跃或未完成。
  • 您正在构建控件、卡片、列表、仪表板、导航、表单或工具栏。
  • 一个组件需要悬停、激活、聚焦、进入、退出、加载或空状态。
  • 前端审查需要具体的改进前/改进后建议。

核心原则

同心圆角

对于附近嵌套的圆角曲面:

外半径 = 内半径 + 内边距

如果内边距很大,则将各层视为单独的曲面,而不是强制套用公式。重点是视觉上的连贯性,而不是对公式的崇拜。

光学对齐

几何中心并不总是视觉中心。图标按钮、播放三角、箭头、星形和非对称图标通常需要微小的偏移。尽可能修复 SVG;否则,使用像素级别的外边距或内边距调整。

阴影和边框

使用边框进行分隔和聚焦环。当卡片、按钮、下拉菜单或弹出窗口需要深度感时,使用分层阴影。阴影应是透明的且足够柔和,以适应不同背景。

文本换行

  • 在标题和短标题上使用 text-wrap: balance。
  • 在短到中等长度的正文文本、说明、描述和列表项上使用 text-wrap: pretty。
  • 避免在长篇散文、代码和预格式化内容上使用这两者。
  • 对计数器、计时器、价格、表格和其他会变化的数字,使用 font-variant-numeric: tabular-nums。

字体平滑

在 macOS 上,如果项目尚未设置,则在根布局应用抗锯齿字体平滑:

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

图像轮廓

图像通常需要一个微妙的内部轮廓,以免其边缘与背景模糊成一片。

img {
  outline: 1px solid rgba(0, 0, 0, 0.1);
  outline-offset: -1px;
}

@media (prefers-color-scheme: dark) {
  img {
    outline-color: rgba(255, 255, 255, 0.1);
  }
}

使用中性黑色或白色的 alpha 轮廓。不要使用品牌调色板为图像轮廓着色。

动效

对交互状态变化使用 CSS 过渡,因为当用户在动画中途改变意图时,它们可以重新定位目标。将关键帧保留用于分阶段的一次性入场或加载序列。

良好的动效默认值:

  • 进入:结合透明度、微小的 translateY,可选地结合模糊。
  • 退出:比进入更短更安静,通常为 150ms。
  • 按压:使用 scale(0.96) 获得触觉反馈按钮,并提供一种在移动分散注意力时禁用的方法。
  • 图标切换:使用透明度、缩放和模糊进行淡入淡出,而不是立即切换可见性。

过渡范围

切勿使用 transition: all。指定发生变化的属性:

.button {
  transition-property: transform, background-color, box-shadow;
  transition-duration: 150ms;
  transition-timing-function: ease-out;
}

仅在合成层友好的属性(如 transform、opacity 和 filter)上,为解决首帧卡顿问题而使用 will-change。切勿使用 will-change: all。

点击区域

交互式控件应至少具有 40x40 像素的点击区域,理想情况下,在布局允许时为 44x44 像素。当可见图标较小时,使用伪元素进行扩展,但不要让扩展的点击区域重叠。

审查输出

审查 UI 润色时,以改进前/改进后表格的形式报告具体更改:

原则改进前改进后
同心圆角父级和子级使用相同半径父级半径考虑了内边距
表格数字计数器随数字变化而跳动计数器使用 tabular-nums
过渡范围transition: all明确的过渡属性

如果代码片段不明显,请包含文件路径和属性。省略那些您已检查但未更改的原则。

检查清单

  • 嵌套的圆角元素在视觉上是连贯的。
  • 图标在视觉上居中。
  • 按钮、卡片和弹出窗口因正确的理由使用边框或阴影。
  • 标题和短文本避免尴尬的换行。
  • 动态数字使用表格数字。
  • 图像在需要时有中性轮廓。
  • 进入和退出动画是分开的、微妙的,并且在适当时可中断。
  • 按钮具有触觉激活状态,且没有夸张的动效。
  • transition: all 和 will-change: all 不存在。
  • 小型控件仍然有可用的点击区域。

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

accessibility

Design, implement, and audit inclusive digital products using WCAG 2.2 Level AA. Use when building or auditing UI that must meet WCAG 2.2 Level AA, or when reviewing a change for keyboard, contrast, or screen-reader support.

affaan-m/claude-api

Anthropic Claude API patterns for Python and TypeScript. Covers Messages API, streaming, tool use, vision, extended thinking, batches, prompt caching, and Claude Agent SDK. Use when building applications with the Claude API or Anthropic SDKs.

affaan-m/everything-claude-code

End-to-end marketing campaign planning and execution. Covers audience research, positioning, campaign angle definition, landing page copy, email sequences, social posts, ad copy, short-form video scripts, and content calendars. Use as the orchestration layer for multi-channel product launches. Use when planning or executing a multi-channel product launch, or producing landing page, email, social, or ad copy.

affaan-m/everything-claude-code

Development conventions and patterns for everything-claude-code. JavaScript project with conventional commits.

affaan-m/everything-claude-code-conventions

Development conventions and patterns for everything-claude-code. JavaScript project with conventional commits.

affaan-m/frontend-design

Create distinctive, production-grade frontend interfaces with high design quality. Use when the user asks to build web components, pages, or applications and the visual direction matters as much as the code quality.

affaan-m/gget

gget CLI and Python workflow for quick genomic database queries, sequence lookup, BLAST-style searches, enrichment checks, and reproducible bioinformatics evidence logs.

affaan-m/literature-review

Systematic literature-review workflow for academic, biomedical, technical, and scientific topics, including search planning, source screening, synthesis, citation checks, and evidence logging.

affaan-m/motion-ui

Production-ready UI motion system for React/Next.js. Use when implementing animations, transitions, or motion patterns.

affaan-m/project-guidelines-example

Example project-specific skill template based on a real production application.

affaan-m/pubmed-database

Direct PubMed and NCBI E-utilities search workflows for biomedical literature, MeSH queries, PMID lookup, citation retrieval, and API-backed literature monitoring.

affaan-m/scholar-evaluation

Structured scholarly-work evaluation for papers, proposals, literature reviews, methods sections, evidence quality, citation support, and research-writing feedback.

affaan-m/uspto-database

USPTO patent and trademark data workflow for official record lookup, PatentSearch queries, TSDR checks, assignment data, and reproducible IP research logs.

agent-architecture-audit

Full-stack diagnostic for agent and LLM applications. Audits the 12-layer agent stack for wrapper regression, memory pollution, tool discipline failures, hidden repair loops, and rendering corruption. Produces severity-ranked findings with code-first fixes. Essential for developers building agent applications, autonomous loops, or any LLM-powered feature. Use when an agent or LLM feature misbehaves and the failing layer is unknown, or before shipping an agent stack.

agent-eval

Head-to-head comparison of coding agents (Claude Code, Aider, Codex, etc.) on custom tasks with pass rate, cost, time, and consistency metrics. Use when choosing between coding agents, or when a change to an agent setup needs measured pass rate, cost, and time rather than an impression.

agent-harness-construction

Design and optimize AI agent action spaces, tool definitions, and observation formatting for higher completion rates. Use when defining or revising an agent

agentic-engineering

Operate as an agentic engineer using eval-first execution, decomposition, and cost-aware model routing. Use when planning or executing engineering work that agents will carry out end to end.

agentic-os

Build persistent multi-agent operating systems on Claude Code. Covers kernel architecture, specialist agents, slash commands, file-based memory, scheduled automation, and state management without external databases. Use when building a persistent multi-agent system on Claude Code with its own memory, commands, and scheduling.

agent-introspection-debugging

Structured self-debugging workflow for AI agent failures using capture, diagnosis, contained recovery, and introspection reports. Use when an agent run fails and you need a reproducible diagnosis instead of a retry.

agent-payment-x402

Add x402 payment execution to AI agents with per-task budgets, spending controls, and non-custodial wallets. Supports Base through agentwallet-sdk and X Layer through OKX Payments / OKX Agent Payments Protocol. Use when an agent must pay for something itself and needs per-task budgets, spending controls, and a non-custodial wallet.

相关技能