图标
约 278 字小于 1 分钟
2024-08-18
概述
图标组件 <Icon />,根据 markdown.icon 配置,从不同的图标库加载图标。
配置
.vuepress/config.ts
import { defineUserConfig } from 'vuepress'
import { plumeTheme } from 'vuepress-theme-plume'
export default defineUserConfig({
theme: plumeTheme({
markdown: {
icon: { provider: 'iconify' } // 默认支持
}
})
})interface IconOptions {
/**
* 图标提供商
*/
provider: 'iconify' | 'iconfont' | 'fontawesome'
/**
* 图标默认前缀,不同的提供商默认前缀不同
* - iconify - 默认为 `''`
* - iconfont - 默认为 `iconfont icon-`
* - fontawesome - 默认为 `fas`
*/
prefix?: string
/**
* 图标资源地址
*/
assets?: IconAssetLink | IconAssetLink[]
size?: string | number
color?: string
}Props
Name:nameOptionalType:string
Default Value: ''
图标名称,当 markdown.icon.prefix 有值时,name 中的前缀可以省略
Name:colorOptionalType:string
Default Value: currentColor
图标颜色
Name:sizeOptionalType:string
Default Value: 1em
图标大小
示例
输入:
- home - <Icon name="material-symbols:home" color="currentColor" size="1em" />
- vscode - <Icon name="skill-icons:vscode-dark" size="2em" />
- twitter - <Icon name="skill-icons:twitter" size="2em" />输出:
- home -
- vscode -
- twitter -
贡献者
更新日志
2026/9/9 07:33
查看所有更新日志
1d04d-feat: add builtin auto-import-components (#932)于16c2d-docs: update field container于4d236-feat(theme)!: add collections support (#704)于14973-feat: add multiple provider support for icon, close #568 (#596)于d1496-docs: update docs于0fd6c-refactor(theme): improve types and flat config (#524)于e3b1c-docs: improve docs于
