@i316/heroicons-vue
v0.1.1
Published
i316: Heroicons icons as tree-shakeable Vue 3 components.
Maintainers
Readme
@i316/heroicons-vue
i316: Heroicons icons as Vue 3 components. 324 icons in 2 styles: outline (default), solid.
Other i316 Heroicons packages: @i316/heroicons-react (React web), @i316/heroicons-react-native (React Native), @i316/heroicons-angular (Angular) and @i316/heroicons-web (plain HTML web component and raw SVGs).
npm install @i316/heroicons-vueUsage
<script setup lang="ts">
// One style: every icon is exported as both `Bell` and `BellIcon`.
import { ChevronDown, BellIcon } from '@i316/heroicons-vue/outline';
// Any style from the root: <Name><Style>Icon, or <Name>Icon to switch style at runtime.
import { BellSolidIcon, HomeIcon } from '@i316/heroicons-vue';
</script>
<template>
<ChevronDown :size="20" color="#e11d48" />
<BellSolidIcon class="text-slate-500" title="Notifications" />
<HomeIcon :variant="isActive ? 'solid' : 'outline'" />
</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 { HeroIconProvider } from '@i316/heroicons-vue';
</script>
<template>
<HeroIconProvider :size="20" :stroke-width="2" class-name="shrink-0">
<RouterView />
</HeroIconProvider>
</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/heroicons-vue/dynamic';
</script>
<template>
<DynamicIcon :name="item.icon" variant="solid">
<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/heroicons-vue/babel'] };Props
| Prop | Default | |
|---|---|---|
| size | 24 | width and height |
| color | currentColor | icon color |
| strokeWidth | 1.5 | outline only; ignored by the other styles |
| title | none | accessible name (see below) |
| variant | outline | <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 hero-icon hero-icon-<name> (e.g. hero-icon-chevron-down).
Editor previews: hovering an icon imported from a style path (@i316/heroicons-vue/outline) 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: Heroicons by Tailwind Labs (https://github.com/tailwindlabs/heroicons), licensed under MIT. i316 modified them: 24px outline and solid sets only, recolored to currentColor and reformatted; 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.
