Npm Badge
About 662 wordsAbout 2 min
2025-10-08
Overview
The Npm Badge component is used to display npm package information and provide relevant links.
The badges are powered by https://shields.io.
Usage
The component does not need to be registered; the theme will automatically import the NpmBadge and NpmBadgeGroup components on demand.
Use them directly in markdown files:
<!-- use them in markdown -->
<NpmBadge name="vuepress-theme-plume" type="dm" />
<!-- Display multiple npm badges side by side -->
<NpmBadgeGroup name="vuepress-theme-plume" items="version,dm" /><NpmBadge />
Single npm badge
Props
Optional
stringPackage GitHub repository address in owner/repo format. Required when name is empty
Types
type NpmBadgeType
// github
= | 'source' // github source
| 'stars' // github stars
| 'forks' // github forks
| 'license' // github license
// npm
| 'version' // npm version
| 'dt' // alias d18m
| 'd18m' // npm downloads last 18 months
| 'dw' // npm downloads weekly
| 'dm' // npm downloads monthly
| 'dy' // npm downloads yearly
type NpmBadgeTheme = 'flat' | 'flat-square' | 'plastic' | 'for-the-badge' | 'social'Examples
<NpmBadge repo="pengzhanbo/vuepress-theme-plume" type="source" />-<NpmBadge repo="pengzhanbo/vuepress-theme-plume" type="stars" />-<NpmBadge repo="pengzhanbo/vuepress-theme-plume" type="forks" />-<NpmBadge repo="pengzhanbo/vuepress-theme-plume" type="license" />-<NpmBadge name="vuepress-theme-plume" type="version" />-<NpmBadge name="vuepress-theme-plume" type="dt" />-<NpmBadge name="vuepress-theme-plume" type="d18m" />-<NpmBadge name="vuepress-theme-plume" type="dy" />-<NpmBadge name="vuepress-theme-plume" type="dm" />-<NpmBadge name="vuepress-theme-plume" type="dw" />-
<NpmBadgeGroup />
Combines multiple npm badges
Props
Optional
stringPackage GitHub repository address in owner/repo format. Required when name is empty
Optional
string | NpmBadgeType[]Default:[]
List of badge types. When passing a string, separate with ',' and it will be automatically converted to NpmBadgeType[]
Slots
<NpmBadgeGroup /> supports passing multiple <NpmBadge /> components.
The Props declared in <NpmBadgeGroup /> will be injected into the <NpmBadge /> components. This approach is used to implement and simplify badge combinations.
Examples
Input:
<NpmBadgeGroup
repo="pengzhanbo/vuepress-theme-plume"
items="stars,version,dm,source"
/>Output:
Use <slot /> to flexibly define badge combinations:
Input:
<NpmBadgeGroup repo="pengzhanbo/vuepress-theme-plume">
<NpmBadge type="stars" />
<NpmBadge type="version" label="npm" />
<NpmBadge type="dm" />
<NpmBadge type="source" />
</NpmBadgeGroup>Output:
Contributors
Changelog
7a454-feat(plugin-md-power): dropoptionaltag infieldcontainer (#987)on1d04d-feat: add builtin auto-import-components (#932)on16c2d-docs: update field containeron38505-docs: update en docs (#708)on4d236-feat(theme)!: add collections support (#704)on4f60b-style: lint fixond1496-docs: update docson0fd6c-refactor(theme): improve types and flat config (#524)one3b1c-docs: improve docsonac898-docs: update docson
