Typography 字体
我们为不同平台建议了整套的字体规范,力求在不同平台、不同字号下,都能有最佳的阅读体验。
字体





vue
<script lang="ts" setup>
import { isDark } from '~/composables/dark'
</script>
<template>
<div v-if="!isDark" class="demo-term-box">
<img src="/images/typography/term-pingfang.png" alt="" />
<img src="/images/typography/term-hiragino.png" alt="" />
<img src="/images/typography/term-microsoft.png" alt="" />
<img src="/images/typography/term-helvetica.png" alt="" />
<img src="/images/typography/term-arial.png" alt="" />
</div>
<div v-else class="demo-term-box">
<img src="/images/typography/term-pingfang-dark.png" alt="" />
<img src="/images/typography/term-hiragino-dark.png" alt="" />
<img src="/images/typography/term-microsoft-dark.png" alt="" />
<img src="/images/typography/term-helvetica-dark.png" alt="" />
<img src="/images/typography/term-arial-dark.png" alt="" />
</div>
</template>
<style scoped>
img {
width: 220px;
height: 174px;
margin: 0 24px 24px 0;
}
img:nth-of-type(3) {
margin-right: 0;
}
</style>
隐藏源代码
字体规范
层级 | 字号 | 示例 |
辅助文本 | 特小 | Build with Element |
正文 (小) | 小 | Build with Element |
正文 | 基础 | Build with Element |
小标题 | 中 | Build with Element |
标题 | 大 | Build with Element |
主标题 | 特大 | Build with Element |
vue
<template>
<table class="demo-typo-size">
<tbody>
<tr>
<td>Level</td>
<td>Font Size</td>
<td class="color-dark-light">Demo</td>
</tr>
<tr
v-for="(fontSize, i) in fontSizes"
:key="i"
:style="`font-size: var(--el-font-size-${fontSize.type})`"
>
<td>{{ fontSize.level }}</td>
<td>
{{
useCssVar(`--el-font-size-${fontSize.type}`).value +
' ' +
formatType(fontSize.type)
}}
</td>
<td>Build with Element</td>
</tr>
</tbody>
</table>
</template>
<script lang="ts" setup>
import { useCssVar } from '@vueuse/core'
const fontSizes = [
{
level: 'Supplementary text',
type: 'extra-small',
},
{
level: 'Body (small)',
type: 'small',
},
{
level: 'Body',
type: 'base',
},
{
level: 'Small Title',
type: 'medium',
},
{
level: 'Title',
type: 'large',
},
{
level: 'Main Title',
type: 'extra-large',
},
]
function formatType(type: string) {
return type
.split('-')
.map((item) => item.charAt(0).toUpperCase() + item.slice(1))
.join(' ')
}
</script>
隐藏源代码
字体行高

- line-height:1 无行高
- line-height:1.3 紧凑
- line-height:1.5 常规
- line-height:1.7 宽松
vue
<script lang="ts" setup>
import { isDark } from '~/composables/dark'
</script>
<template>
<div>
<img
v-if="isDark"
class="lineH-left"
src="/images/typography/line-height-dark.png"
/>
<img v-else class="lineH-left" src="/images/typography/line-height.png" />
<ul class="lineH-right">
<li>line-height:1 <span>No line height</span></li>
<li>line-height:1.3 <span>Compact</span></li>
<li>line-height:1.5 <span>Regular</span></li>
<li>line-height:1.7 <span>Loose</span></li>
</ul>
</div>
</template>
隐藏源代码
Font-family 字体家族
css
font-family: Inter, 'Helvetica Neue', Helvetica, 'PingFang SC',
'Hiragino Sans GB', 'Microsoft YaHei', '微软雅黑', Arial, sans-serif;