| name | element-plus-design-typography |
| description | Typography design specifications for Element Plus. Invoke when user needs to understand font conventions, font-family settings, or text styling guidelines. |
| metadata | {"author":"jiaiyan","version":"1.0.0"} |
Typography Design Specifications
Element Plus creates font conventions to ensure the best presentation across different platforms.
When to Use
- Understanding font conventions
- Applying consistent text styles
- Setting font-family for cross-platform compatibility
- Managing font sizes and line heights
Font Family
Element Plus uses a carefully selected font stack for optimal cross-platform display:
font-family:
Inter, 'Helvetica Neue', Helvetica, 'PingFang SC', 'Hiragino Sans GB',
'Microsoft YaHei', '微软雅黑', Arial, sans-serif;
Font Stack Explanation
| Font | Platform | Purpose |
|---|
| Inter | All | Primary modern font |
| Helvetica Neue | macOS | System fallback |
| Helvetica | macOS/iOS | System fallback |
| PingFang SC | macOS (Chinese) | Chinese characters |
| Hiragino Sans GB | macOS (Chinese) | Chinese characters |
| Microsoft YaHei | Windows (Chinese) | Chinese characters |
| Arial | All | Universal fallback |
| sans-serif | All | Generic fallback |
Font Sizes
Element Plus provides standardized font size variables:
| Variable | Value | Usage |
|---|
--el-font-size-extra-large | 20px | Extra large headings |
--el-font-size-large | 18px | Large headings |
--el-font-size-medium | 16px | Medium text, subheadings |
--el-font-size-base | 14px | Base body text |
--el-font-size-small | 13px | Small text, captions |
--el-font-size-extra-small | 12px | Extra small text, hints |
Usage Examples
h1 {
font-size: var(--el-font-size-extra-large);
}
h2 {
font-size: var(--el-font-size-large);
}
p {
font-size: var(--el-font-size-base);
}
.caption {
font-size: var(--el-font-size-small);
}
.hint {
font-size: var(--el-font-size-extra-small);
}
Font Weight
| Variable | Value | Usage |
|---|
--el-font-weight-primary | 500 | Primary weight for emphasis |
--el-font-weight-secondary | 100 | Secondary weight for light text |
.emphasis {
font-weight: var(--el-font-weight-primary);
}
.light {
font-weight: var(--el-font-weight-secondary);
}
Line Height
Element Plus provides line height variables for consistent vertical rhythm:
| Variable | Value | Usage |
|---|
--el-font-line-height-primary | 24px | Primary line height |
--el-font-line-height-secondary | 16px | Secondary line height |
Line Height Guidelines
p {
line-height: var(--el-font-line-height-primary);
}
.compact {
line-height: var(--el-font-line-height-secondary);
}
CSS Variables Summary
:root {
--el-font-family: Inter, 'Helvetica Neue', Helvetica, 'PingFang SC',
'Hiragino Sans GB', 'Microsoft YaHei', '微软雅黑', Arial, sans-serif;
--el-font-size-extra-large: 20px;
--el-font-size-large: 18px;
--el-font-size-medium: 16px;
--el-font-size-base: 14px;
--el-font-size-small: 13px;
--el-font-size-extra-small: 12px;
--el-font-weight-primary: 500;
--el-font-weight-secondary: 100;
--el-font-line-height-primary: 24px;
--el-font-line-height-secondary: 16px;
}
Text Component
Element Plus provides a Text component for styled text display:
<template>
<!-- Text types -->
<el-text>Default text</el-text>
<el-text type="primary">Primary text</el-text>
<el-text type="success">Success text</el-text>
<el-text type="warning">Warning text</el-text>
<el-text type="danger">Danger text</el-text>
<el-text type="info">Info text</el-text>
<!-- Text sizes -->
<el-text size="large">Large text</el-text>
<el-text size="default">Default text</el-text>
<el-text size="small">Small text</el-text>
<!-- Truncated text -->
<el-text truncated>Long text that will be truncated...</el-text>
<!-- Line clamped text -->
<el-text :line-clamp="2">Long text clamped to 2 lines...</el-text>
</template>
Best Practices
- Use CSS Variables: Always use predefined font variables for consistency
- Cross-Platform: The font stack ensures consistent display across platforms
- Hierarchy: Use font sizes to establish visual hierarchy
- Line Height: Maintain readable line heights for body text
- Dark Mode: Typography automatically adjusts in dark mode
- Chinese Support: Font stack includes Chinese-optimized fonts
Related Resources