首页/ AI 技能 / @skilllib/skill-2014279382427185154
Skill站外收录 @skilllib/skill-2014279382427185154

styling

减少冗余包装元素,优先将样式类直接应用于语义化标签,在保持结构语义的前提下通过工具函数合并条件样式,使用原子化工具类构建 UI 并借助设计变量确保视觉一致性。

0.0 (0) 542 次安装 原作者 编程导航
收录于 2026-01-22
软件开发 AI 技能

Skills.MD

# Styling Guidelines ## Minimize Wrapper Elements Avoid creating unnecessary wrapper divs. If classes can be applied directly to an existing semantic element with the same outcome, prefer that approach. ### Good (Direct Application) ```svelte <main class="flex-1 mx-auto max-w-7xl"> {@render children()} </main> ``` ### Avoid (Unnecessary Wrapper) ```svelte <main class="flex-1"> <div class="mx-auto max-w-7xl"> {@render children()} </div> </main> ``` This principle applies to all elements where the styling doesn't conflict with the element's semantic purpose or create layout issues. ## Tailwind Best Practices - Use the `cn()` utility from `$lib/utils` for combining classes conditionally - Prefer utility classes over custom CSS - Use `tailwind-variants` for component variant systems - Follow the `background`/`foreground` convention for colors - Leverage CSS variables for theme consistency

评论 0

还没有评论,来抢沙发。