@i316/phosphor-vue
v0.1.1
Published
i316: Phosphor icons as tree-shakeable Vue 3 components.
Maintainers
Readme
@i316/phosphor-vue
i316: Phosphor icons as Vue 3 components. 1,512 icons in 6 styles: thin, light, regular (default), bold, fill, duotone.
Other i316 Phosphor packages: @i316/phosphor-react (React web), @i316/phosphor-react-native (React Native), @i316/phosphor-angular (Angular) and @i316/phosphor-web (plain HTML web component and raw SVGs).
npm install @i316/phosphor-vueUsage
<script setup lang="ts">
// One style: every icon is exported as both `Bell` and `BellIcon`.
import { CaretDown, BellIcon } from '@i316/phosphor-vue/regular';
// Any style from the root: <Name><Style>Icon, or <Name>Icon to switch style at runtime.
import { BellBoldIcon, HouseIcon } from '@i316/phosphor-vue';
</script>
<template>
<CaretDown :size="20" color="#e11d48" />
<BellBoldIcon class="text-slate-500" title="Notifications" />
<HouseIcon :variant="isActive ? 'bold' : 'regular'" />
</template>Works with server-side rendering (Nuxt, @vue/server-renderer). class, style, listeners and other attributes fall through to the root <svg>.
Defaults for a subtree
<script setup lang="ts">
import { PhosphorIconProvider } from '@i316/phosphor-vue';
</script>
<template>
<PhosphorIconProvider :size="20" class-name="shrink-0">
<RouterView />
</PhosphorIconProvider>
</template>Props on an icon override the provider. Nested providers override their parent's values.
Icons chosen at runtime
<script setup lang="ts">
import { DynamicIcon } from '@i316/phosphor-vue/dynamic';
</script>
<template>
<DynamicIcon :name="item.icon" variant="bold">
<template #fallback><Spinner /></template>
</DynamicIcon>
</template>Each icon is loaded as its own chunk the first time it renders. This is opt-in: only apps that import /dynamic pay for its map of every icon name.
Tree-shaking
Every icon is its own module and the package is sideEffects-free, so Vite, webpack and Nuxt production builds ship only the icons you import. For unbundled toolchains (Jest, webpack in development), add the bundled Babel plugin, which rewrites barrel imports into per-icon imports:
// babel.config.js
module.exports = { plugins: ['@i316/phosphor-vue/babel'] };Props
| Prop | Default | |
|---|---|---|
| size | 24 | width and height |
| color | currentColor | icon color |
| secondaryColor | color | color of the translucent layer, duotone only |
| secondaryOpacity | as designed | opacity of that layer, duotone only |
| title | none | accessible name (see below) |
| variant | regular | <Name>Icon and DynamicIcon only: which style to render |
Accessibility: icons are decorative by default (aria-hidden="true"). Pass title to make one meaningful: it renders a <title> with role="img". Passing your own aria-label or role also removes aria-hidden.
Styling: every icon has the classes phosphor-icon phosphor-icon-<name> (e.g. phosphor-icon-caret-down).
Editor previews: hovering an icon imported from a style path (@i316/phosphor-vue/regular) in VS Code shows a picture of it. Root imports have no previews, which keeps them light for the editor.
ESM only, with TypeScript declarations. Peer dependency: vue >= 3.2.
License
Icons: Phosphor Icons (https://github.com/phosphor-icons/core), licensed under MIT. i316 modified them: reformatted and grouped into folders by each icon's primary upstream category; converted into React, React Native, Vue, Angular and web-component formats.
i316 code (components, runtime, tooling): MIT, © 2026 rahil316. See LICENSE for both licenses in full.
