Svelte Heros V2
Svelte-Heros-v2
If you are looking for the version 1, go to Svelte-Heros
Hero Icons v2 uses Heroicon v2 to create Svelte SVG icons. You can select outline and solid icons using the variation props. Svlete-Heros support major CSS framework. You can add additional CSS using the class
props.
Installation
npm i -D svelte-heros-v2
To update
npm i -D svelte-heros-v2@latest
REPL
Outline demo
Solid demo
List of icons
Icon names
Icon images
Icon images
Usage
<script>
import { AcademicCap } from 'svelte-heros-v2';
</script>
<AcademicCap />
Faster compiling
For faster compilation, you can import the icon directly.
<script>
import AcademicCap from 'svelte-heros-v2/AcademicCap.svelte';
</script>
<AcademicCap />
If you are TypeScript user, this require "typescript": "^5.0.0"
.
As of March 2023, the typescript@beta
version is now available:
pnpm i -D typescript@beta
To avoid any complaints from the editor, add node16
or nodenext
to moduleResolution
in your tsconfig.json file.
{
"compilerOptions": {
"moduleResolution": "nodenext"
}
}
Props
size | 24 |
class | |
ariaLabel | file name |
variation (solid or outline) | outline |
focus | false |
Variation
The default variation value is outline. Use the variation
prop to change it to solid.
<AcademicCap variation="solid" />
Size
Use the size
prop to change the size of icons.
<AcademicCap size="30" />
<AcademicCap size="40" />
<AcademicCap size="50" />
Unfocusable icon
If you want to make an icon unfocusable, add tabindex="-1"
.
<AcademicCap tabindex="-1" />
CSS HEX Colors
Use the color
prop to change colors with HEX color code.
<AcademicCap color="#ff0000" /> <AcademicCap color="#00ffd8" />
Stroke width
Use the strokeWidth
prop to change the SVG stroke-width
.
<AcademicCap strokeWidth="4" size="100" />
CSS framework support
Use the class
prop to change colors and additional CSS.
For example, Tailwind CSS:
<AcademicCap class="text-pink-700 mr-4" />
If you use the dark mode on your website with Tailwind CSS, add your dark mode class to the class
prop.
Let's use dark
for the dark mode class as an example.
<AcademicCap class="text-pink-700 dark:text-blue-300" />
Bootstrap example:
<AcademicCap class="position-absolute top-0 px-1" />
aria-label
All icons have aria-label. For example AcademicCap
has aria-label="academic cap"
.
Use ariaLabel
prop to modify the aria-label
value.
<AcademicCap ariaLabel="red academic cap" class="text-red-500"></AcademicCap>
Passing down other attributes
You can pass other attibutes as well.
<AcademicCap tabindex="0" />
Using svelte:component
<script>
import { AcademicCap } from 'svelte-heros-v2';
</script>
<svelte:component this="{AcademicCap}" size="40" />
Import all
Use import * as Icon from 'svelte-heros-v2'
.
<script>
import * as Icon from 'svelte-heros-v2';
</script>
<Icon.ShoppingBag size="30" class="text-red-500" />
<Icon.Sparkles size="40" class="text-blue-700" />
<Icon.Star size="50" class="text-green-700" />
<Icon.User size="60" class="text-purple-500" />
<Icon.Wifi size="100" class="text-purple-500" tabindex="0" />
Dynamically change the variation
<script>
import { Map } from 'svelte-heros-v2';
let isSolid = false;
</script>
<Map size="50" on:click={() => (isSolid = !isSolid)} variation={isSolid ? 'solid' : 'outline'} />
Events
All icons have the following events:
on:click
on:mouseenter
on:mouseleave
on:mouseover
on:mouseout
on:blur
on:focus
Original source
tailwindlabs/heroicons v2.0.13
Other icons
Experience lightning-fast browsing and offline access with Our PWA
This website can be downloaded and installed on your device for offline access as a Progressive Web App.
To install a PWA, look for the "Add to Home Screen" option in the browser's menu or settings. On most mobile devices, this option can be found by visiting the website, then selecting the "Options" or "Menu" button in the browser, and looking for the "Add to Home Screen" option. On some desktop browsers, right-click on the page and select "Install".