StyleKit

前端百科全书

前端基础

把「好看」拆开讲透——从色彩、字体、字号、间距,到设计原则与视觉层次。不只给你素材,更教你为什么。一页学完前端的视觉系统。

系统层 · 基础

色彩理论

好看的配色不是凭感觉——它建立在色相、饱和度、明度三个维度,和一套可推导的和谐关系之上。这里教你原理,并给你能直接复制的工具。

01

原理:HSL 三维度

任何颜色都能拆成色相(是什么色)、饱和度(多鲜艳)、明度(多亮)。拖动滑块,感受每个维度。

#2662d9 · hsl(220, 70%, 50%)
色轮上的位置 0-360°
220
0=灰, 100=鲜艳
70
0=黑, 50=纯色, 100=白
50
02

配色和谐生成器

从上面的基色出发,色轮上的固定角度会生成和谐的配色。点任意色板复制 CSS 变量。

互补
分裂互补
类比
三角
四角
单色
03

对比度检查 (WCAG)

文字与背景的对比度决定可读性。WCAG 要求正文至少 4.5:1 (AA),理想 7:1 (AAA)。

可读性预览 Aa

#1f2937
#ffffff
14.68:1
AAA

通过,可安全用于文字。

04

选用指南

原理之外,几条经验法则能立刻让配色更专业。

60-30-10 法则

主色 60%、次色 30%、强调色 10% —— 平衡又有重点。

暖色 vs 冷色

暖色(红橙黄)前进、有活力;冷色(蓝绿紫)后退、显冷静。

语义色

用户对这几种颜色有固定预期 —— 别违背它。

成功
#22c55e
警告
#eab308
错误
#ef4444
信息
#3b82f6

精选字体方向

有明确气质的字体

经过重新筛选的开源字体组合,针对真实界面风格而设计。比较字形、了解适用场景,并复制可直接使用的 CSS 或 Tailwind 字体令牌。

预览字号

共 41 个配对

ElegantGloock × Manrope
Aa Gg Qq Rg 0123 &?

Maison & Atelier

Refined contrast and graceful proportion lend a quiet luxury to fashion, beauty, and premium editorial work.

画廊格洛克

OFL

ClassicAlegreya × Source Sans 3
Aa Gg Qq Rg 0123 &?

Timeless by Design

Considered typography that endures. Every letterform carries tradition while remaining comfortable for long-form reading.

文学档案

OFL

ClassicYeseva One × Karla
Aa Gg Qq Rg 0123 &?

Timeless by Design

Considered typography that endures. Every letterform carries tradition while remaining comfortable for long-form reading.

叶塞娃沙龙

OFL

ModernBricolage Grotesque × Albert Sans
Aa Gg Qq Rg 0123 &?

Built for Tomorrow

Clean lines and confident spacing shape interfaces that feel effortless, fast, and unmistakably current.

布里科工作室

OFL

ModernArchivo Black × Archivo
Aa Gg Qq Rg 0123 &?

Built for Tomorrow

Clean lines and confident spacing shape interfaces that feel effortless, fast, and unmistakably current.

阿奇沃海报

OFL

PlayfulDela Gothic One × Nunito Sans
Aa Gg Qq Rg 0123 &?

Hello, Sunshine!

Bright, friendly type for products that keep the experience light without becoming childish.

德拉潮流

OFL

EditorialYoung Serif × Work Sans
Aa Gg Qq Rg 0123 &?

The Morning Edition

Long-form reading deserves rhythm and contrast. A serif headline sets the tone; the body face carries the story.

青年艺术书

OFL

EditorialKalnia × Commissioner
Aa Gg Qq Rg 0123 &?

The Morning Edition

Long-form reading deserves rhythm and contrast. A serif headline sets the tone; the body face carries the story.

卡尔尼亚博物馆

OFL

TechnicalFragment Mono × Albert Sans
Aa Gg Qq Rg 0123 &?

System Architecture

Monospace precision meets readable prose for documentation, dashboards, and dependable technical interfaces.

片段信号

OFL

TechnicalAzeret Mono × Public Sans
Aa Gg Qq Rg 0123 &?

System Architecture

Monospace precision meets readable prose for documentation, dashboards, and dependable technical interfaces.

阿泽雷特系统

OFL

DisplayUnbounded × Manrope
BEYOND
Aa Gg Qq Rg 0123 &?

无界未来

OFL

DisplayBungee × Archivo
BLOCK PARTY
Aa Gg Qq Rg 0123 &?

蹦极街头

OFL

DisplayLimelight × Karla
CINEMA
Aa Gg Qq Rg 0123 &?

聚光灯装饰

OFL

DisplayGrenze Gotisch × Manrope
NOCTURNE
Aa Gg Qq Rg 0123 &?

格伦策夜曲

OFL

HandwrittenShantell Sans × Atkinson Hyperlegible
Made by hand
Aa Gg Qq Rg 0123 &?

香特尔手作

OFL

ModernSora × Figtree
Aa Gg Qq Rg 0123 &?

Built for Tomorrow

Clean lines and confident spacing shape interfaces that feel effortless, fast, and unmistakably current.

Sora 产品

OFL

ModernEpilogue × Hanken Grotesk
Aa Gg Qq Rg 0123 &?

Built for Tomorrow

Clean lines and confident spacing shape interfaces that feel effortless, fast, and unmistakably current.

Epilogue 无衬线

OFL

TechnicalIBM Plex Sans × IBM Plex Sans
Aa Gg Qq Rg 0123 &?

System Architecture

Monospace precision meets readable prose for documentation, dashboards, and dependable technical interfaces.

Plex 技术

OFL

DisplaySyne × Hanken Grotesk
AVANT
Aa Gg Qq Rg 0123 &?

Syne 前卫

OFL

ClassicLibre Caslon Display × Source Sans 3
Aa Gg Qq Rg 0123 &?

Timeless by Design

Considered typography that endures. Every letterform carries tradition while remaining comfortable for long-form reading.

卡斯隆期刊

OFL

EditorialNewsreader × Figtree
Aa Gg Qq Rg 0123 &?

The Morning Edition

Long-form reading deserves rhythm and contrast. A serif headline sets the tone; the body face carries the story.

Newsreader 社论

OFL

ClassicSpectral × Work Sans
Aa Gg Qq Rg 0123 &?

Timeless by Design

Considered typography that endures. Every letterform carries tradition while remaining comfortable for long-form reading.

Spectral 阅读

OFL

ModernOutfit × Figtree
Aa Gg Qq Rg 0123 &?

Built for Tomorrow

Clean lines and confident spacing shape interfaces that feel effortless, fast, and unmistakably current.

Outfit 简净

OFL

PlayfulGabarito × Hanken Grotesk
Aa Gg Qq Rg 0123 &?

Hello, Sunshine!

Bright, friendly type for products that keep the experience light without becoming childish.

Gabarito 活力

OFL

TechnicalSpace Mono × Sora
Aa Gg Qq Rg 0123 &?

System Architecture

Monospace precision meets readable prose for documentation, dashboards, and dependable technical interfaces.

等宽终端

OFL

DisplayNabla × Manrope
AURORA
Aa Gg Qq Rg 0123 &?

彩色立体

OFL

DisplayHonk × Work Sans
BLOCK PARTY
Aa Gg Qq Rg 0123 &?

嘉年华招牌

OFL

DisplaySixtyfour × IBM Plex Sans
GAME OVER
Aa Gg Qq Rg 0123 &?

街机 64

OFL

TechnicalDoto × Sora
Aa Gg Qq Rg 0123 &?

System Architecture

Monospace precision meets readable prose for documentation, dashboards, and dependable technical interfaces.

点阵矩阵

OFL

PlayfulPixelify Sans × Nunito Sans
Aa Gg Qq Rg 0123 &?

Hello, Sunshine!

Bright, friendly type for products that keep the experience light without becoming childish.

像素游戏

OFL

DisplayJacquarda Bastarda 9 × Spectral
MIDNIGHT
Aa Gg Qq Rg 0123 &?

哥特织锦

OFL

DisplayRubik Glitch × Hanken Grotesk
SIGNAL LOST
Aa Gg Qq Rg 0123 &?

故障信号

OFL

DisplayMonoton × Karla
OPEN LATE
Aa Gg Qq Rg 0123 &?

霓虹灯管

OFL

PlayfulBagel Fat One × Figtree
Aa Gg Qq Rg 0123 &?

Hello, Sunshine!

Bright, friendly type for products that keep the experience light without becoming childish.

圆胖软糖

OFL

ElegantBodoni Moda × Public Sans
Aa Gg Qq Rg 0123 &?

Maison & Atelier

Refined contrast and graceful proportion lend a quiet luxury to fashion, beauty, and premium editorial work.

时尚博多尼

OFL

ElegantCinzel × Source Sans 3
Aa Gg Qq Rg 0123 &?

Maison & Atelier

Refined contrast and graceful proportion lend a quiet luxury to fashion, beauty, and premium editorial work.

罗马碑刻

OFL

ElegantCormorant Garamond × Karla
Aa Gg Qq Rg 0123 &?

Maison & Atelier

Refined contrast and graceful proportion lend a quiet luxury to fashion, beauty, and premium editorial work.

沙龙加拉蒙

OFL

DisplayBig Shoulders Display × Public Sans
BUILT CITY
Aa Gg Qq Rg 0123 &?

都市工业

OFL

TechnicalMartian Mono × IBM Plex Sans
Aa Gg Qq Rg 0123 &?

System Architecture

Monospace precision meets readable prose for documentation, dashboards, and dependable technical interfaces.

火星任务

OFL

ModernGeist × Geist
Aa Gg Qq Rg 0123 &?

Built for Tomorrow

Clean lines and confident spacing shape interfaces that feel effortless, fast, and unmistakably current.

产品极简

OFL

HandwrittenPlaywrite AU SA × Source Sans 3
Dear you,
Aa Gg Qq Rg 0123 &?

手写笔记

OFL

系统层 · 排版

字号阶梯

字号不该靠猜。模块化比例从一个基准尺寸出发,乘以固定比例得到每一级,让整套排版有统一的数学关系——再用 clamp() 让它随视口流体缩放,无需断点。

一、原理:模块化比例

size = base × ratiostep
16px× 1.25 →
20px× 1.25 →
25px× 1.25 →
31px

基准 16px、比例 1.25(Major Third)下,每一级是上一级的 1.25 倍。基准建议 16px(不是 14/15px),它是浏览器默认正文尺寸。

二、交互生成器

模式
比例

Standard — most products (Stripe/Material)

5xl
字号阶梯让层次清晰
61.04px · 3.8147rem
4xl
字号阶梯让层次清晰
48.83px · 3.0518rem
3xl
字号阶梯让层次清晰
39.06px · 2.4414rem
2xl
字号阶梯让层次清晰
31.25px · 1.9531rem
xl
字号阶梯让层次清晰
25px · 1.5625rem
lg
字号阶梯让层次清晰
20px · 1.25rem
base
字号阶梯让层次清晰
16px · 1rem
sm
字号阶梯让层次清晰
12.8px · 0.8rem
xs
字号阶梯让层次清晰
10.24px · 0.64rem

三、可复制 token

CSS 变量
:root {
  --text-xs: 0.64rem; /* 10.24px */
  --text-sm: 0.8rem; /* 12.8px */
  --text-base: 1rem; /* 16px */
  --text-lg: 1.25rem; /* 20px */
  --text-xl: 1.5625rem; /* 25px */
  --text-2xl: 1.9531rem; /* 31.25px */
  --text-3xl: 2.4414rem; /* 39.06px */
  --text-4xl: 3.0518rem; /* 48.83px */
  --text-5xl: 3.8147rem; /* 61.04px */
}
Tailwind v4 @theme(静态)
@theme {
  --text-xs: 0.64rem;
  --text-sm: 0.8rem;
  --text-base: 1rem;
  --text-lg: 1.25rem;
  --text-xl: 1.5625rem;
  --text-2xl: 1.9531rem;
  --text-3xl: 2.4414rem;
  --text-4xl: 3.0518rem;
  --text-5xl: 3.8147rem;
}

四、选用指南

比例适合
1.125–1.2密集 UI、仪表盘、数据表
1.25–1.333多数产品、SaaS、文档
1.414–1.618编辑、营销、display 主导
  • —基准用 16px——浏览器默认正文尺寸,可读性与无障碍的安全起点。
  • —把每个标题级别映射到阶梯的某一步,而不是写死随意的 px。
  • —正文行宽控制在 55–75ch;正文尺寸保持稳定,不要做 fluid——只让 display / heading 流体缩放。
  • —字号越大行高越紧:大标题约 1.1,正文约 1.5——垂直律动随尺寸调整。
  • —不确定就从 1.25 起;层次太平再加大比例。别把 1.618 强加到密集 UI 上。

系统层 · 布局

间距与网格

间距是布局的节奏。把所有 padding、margin、gap 都约束到一个 8 像素的网格上,页面就有了统一的呼吸感——而不是一堆随手定的 13px、17px。

一、原理:8 点网格

8
16
24
32
48
64

所有间距都是 8 的倍数(4px 作为精细的半步)。为什么是 8?常见屏幕密度 1×、1.5×、2×、3× 都能整除 8,得到整数像素——所以 8px 的内边距在手机、桌面、高清屏上都像素完美,而 5px、7px 会因子像素渲染发虚。

二、交互演示

网格基准
0
0px · 0rem
xs
4px · 0.25rem
sm
8px · 0.5rem
md
16px · 1rem
lg
24px · 1.5rem
xl
32px · 2rem
2xl
48px · 3rem
3xl
64px · 4rem
4xl
96px · 6rem
5xl
128px · 8rem
Snap 检查器
px不在网格上 — 应 snap 到 16px

铁律:值要么落在阶梯上,要么扩展阶梯——绝不在原地发明 13px。

列网格

12 列 · gutter 32px · margin 24px。12 整除 2/3/4/6,半/三分/四分/六分都能对齐。

三、可复制 token

CSS 变量
:root {
  --space-0: 0rem; /* 0px */
  --space-xs: 0.25rem; /* 4px */
  --space-sm: 0.5rem; /* 8px */
  --space-md: 1rem; /* 16px */
  --space-lg: 1.5rem; /* 24px */
  --space-xl: 2rem; /* 32px */
  --space-2xl: 3rem; /* 48px */
  --space-3xl: 4rem; /* 64px */
  --space-4xl: 6rem; /* 96px */
  --space-5xl: 8rem; /* 128px */
}
Tailwind v4 @theme
@theme {
  --spacing-0: 0rem;
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;
  --spacing-2xl: 3rem;
  --spacing-3xl: 4rem;
  --spacing-4xl: 6rem;
  --spacing-5xl: 8rem;
}

四、选用指南

  • —默认用 8pt——主流且跨设备像素完美;只在密集 UI(仪表盘、数据表)才降到 4pt 精细。
  • —snap 不发明:组件用了 13px,下一个就会用 14px,系统的节奏就垮了。
  • —区分 micro 与 macro:组件内间距(micro)移动端保持不变;页面级间距(macro,section/hero)移动端缩小。
  • —布局用 12 列网格,gutter 16–24px、外边距桌面 24 / 移动 16;gutter 和 margin 也用间距 token。
  • —常见尺寸落在网格上:按钮高 40/48、图标 16/24/32、卡片内边距 16/24、触摸目标不小于 44×44。

系统层 · 设计原理

设计四原则 · CRAP

色彩、字体、字号、间距给你正确的元素;CRAP 教你怎么组织它们。对比、重复、对齐、亲密性——四条原则把一堆正确的 token 变成一个看起来「刻意」的版面。

一、四原则

C对比

如果两个元素不一样,就让它们明显不一样,绝不似是而非。对比建立层次,把视线引向最重要的东西。

别犹豫——元素要有别,就让差异够大。

R重复

在整个设计中重复视觉元素——颜色、形状、字体、间距。重复建立统一感,让布局像一个系统,而不是零散的拼凑。

到处复用同一套 token——一致会被读成「刻意」。

A对齐

页面上每个元素都该和别的元素有视觉连接。没有东西是随手一放的——共享的边线和基线建立起一种眼睛信赖的隐形秩序。

没有东西该飘着——一切都落在共享的边线或基线上。

P亲密性

把相关的东西聚拢、把无关的推远。亲密性把零散元素归并成几个清晰的单元,减少读者眼睛要做的功。

靠近 = 相关——按含义分组,而不是凭手感。

二、对照演示

切换开关,看同样的内容从「随手摆」变成「守原则」——差距一眼可见。

C对比
更快地构建漂亮界面

一套有层次的排版,胜过十句说明。

R重复
A对齐

产品名称

简短的一句话描述

立即体验

P亲密性
邮箱darling@stylekit.top
电话+86 138 0000 0000
城市北京

三、自查清单与代码

CRAP 自查清单

C — 对比

  • 标题和正文在字号、字重上有明显的跳变,而不是细微差别。
  • 主次操作的视觉重量明显不同。
  • 关键信息靠大小、颜色或字重跳出,而不是只靠斜体。

R — 重复

  • 圆角、阴影、间距都取自同一套共享 token。
  • 同类元素样式一致——每张卡片都像卡片。
  • 品牌色和字体在各区块反复出现,把页面串成一体。

A — 对齐

  • 元素共享对齐边,而不是各自为政。
  • 同一区块里避免居中与左对齐混用。
  • 用网格或共享左边线约束元素的落点。

P — 亲密性

  • 标签紧贴它所描述的输入框,而不是漂在两者之间。
  • 相关项成组,组与组之间的留白大于组内留白。
  • 孤立、未分组的元素被归入它所属的单元。
C · 对比
.title {
  font-size: 2.5rem;
  font-weight: 700;
}
.body {
  font-size: 1rem;
  font-weight: 400;
  color: var(--muted);
}
R · 重复
:root {
  --radius: 8px;
  --shadow: 0 1px 3px rgb(0 0 0 / 0.1);
}
.card {
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
A · 对齐
.form {
  display: grid;
  gap: 12px;
}
.form > * {
  text-align: left;
}
P · 亲密性
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.form {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

四、选用指南

  • —应用顺序:先用亲密性把内容分组,再用对齐建立秩序,接着用重复统一样式,最后用对比拉开主次。先理结构,再强化。
  • —对比最忌「差一点」:almost the same 是最糟的——要么相同,要么明显不同。
  • —对齐别混用:同一区块里居中和左对齐混排,秩序立刻垮掉。
  • —落回材料层:对比落到字号/字重/色彩,重复与亲密性落到间距 token,对齐落到网格——CRAP 是「用法」,前四块是「材料」。

系统层 · 注意力

视觉层次

视觉层次是对「眼睛先看什么、后看什么」的控制。四个杠杆——大小、字重、颜色对比、留白——决定了每个元素的视觉重量,进而决定注意力的流动顺序。

一、四个杠杆

大小

更大的元素先被看到——大小是房间里最响亮的信号。

字重

更重的笔画有更大的视觉质量,留住视线更久。

颜色对比

与背景高对比的跳到前面,灰暗的色调后退。

留白

留白与隔离给元素空间去掌控注意力。

二、杠杆调节器

打开/关闭杠杆,左侧序号是眼睛的扫描顺序(按视觉重量实时排序)。全部关闭,一切扁平、只能从上往下硬扫;逐个打开,主次秩序浮现。

杠杆
3
新版发布眉标
1
会自己上线的设计标题
4
一段支撑标题、又不与它争抢的简短说明。正文
2
按钮
5
2 天前更新元信息

三、可复制:文本层级

把层次固化成三级文本 token——主、次、辅。用相对字号、字重、不透明度区分,而不是每次现调。

CSS 文本层级
.text-primary {
  font-size: 1.5rem;
  font-weight: 700;
  opacity: 1;
}
.text-secondary {
  font-size: 1rem;
  font-weight: 500;
  opacity: 0.9;
}
.text-tertiary {
  font-size: 0.875rem;
  font-weight: 400;
  opacity: 0.6;
}

四、选用指南

  • —每屏一个主焦点:先决定眼睛最先该落在哪,再让其他一切退后。两个并列的「第一」等于没有第一。
  • —层级控制在 3-4 级:主、次、辅足够;级数越多,每级的差异越被稀释。
  • —杠杆叠加、但别全开满:标题同时放大 + 加粗就够,再叠满色彩和留白会过载。
  • —别只靠颜色:色彩对比对色盲用户失效,层次要同时落在大小或字重上,才经得起可访问性。