Nerdfont SVG-Icons for Svelte.js
Run:
npm install --save svelte-nerdfonts
<script>
import Icon from 'svelte-nerdfonts';
import { vim } from 'svelte-nerdfonts/icons/dev';
import { heart } from 'svelte-nerdfonts/icons/mdi';
</script>
<Icon data={vim} />
<Icon data={heart} />
(See cheatsheet to find the icons you are looking for)
Icons can be imported directly from an Iconset or from a combined module prefixed with the name of the iconset.
The iconnames are camelcased versions of the nerdfonts cssclassnames.
// nerd-fonts classname: .nf-linux-archlinux
// all examples will import the same icon
import { default as linuxArchlinux } from 'svelte-nerdfonts/icons/linux/archlinux';
import { archlinux } from 'svelte-nerdfonts/icons/linux';
import { linuxArchlinux } from 'svelte-nerdfonts/icons';
Note: The compiletime depends on the size of the imported iconset. Example 1 will be fastest as it only has to import on iconfile.
svelte-nerdfonts/icons
all icons (prefixed)svelte-nerdfonts/icons/custom
Customsvelte-nerdfonts/icons/dev
Deviconssvelte-nerdfonts/icons/fa
Font Awesomesvelte-nerdfonts/icons/fae
Font Awesome Extensionsvelte-nerdfonts/icons/iec
IEC Power Symbolssvelte-nerdfonts/icons/indentation
svelte-nerdfonts/icons/linux
Font Linuxsvelte-nerdfonts/icons/mdi
Material Designsvelte-nerdfonts/icons/oct
Octiconssvelte-nerdfonts/icons/pl
Powerline Symbolssvelte-nerdfonts/icons/ple
PowerLine Extra Symbolssvelte-nerdfonts/icons/pom
Pomiconssvelte-nerdfonts/icons/seti
Seti UIsvelte-nerdfonts/icons/weather
Weather IconsIf you are using vim/neovim with
fzf.vim
you can install the svelte_nerdfonts.vim
plugin
to find, import and add icons more efficently.
Install with vim-plug
Plug 'icalvin102/svelte-nerdfonts', { 'rtp': 'vim' }
Or install the vim
directory manually.
The plugin will give you the :SNFAddImport
and :SNFAddIcon
commands which are mapped to <leader>si
and <leader>sI
by default.
:SNFAddImport
Find icons and add ESM import statements.:SNFAddIcon
Search through imported icons and add Icon
componentMultiple selection is possible with Tab
(select down)
and Shift+Tab
(select up). Press Enter
to confirm and insert
the selected icons into your buffer.
Note: Install a nerd-font for icon-previews in the fzf output
$ git clone https://github.com/icalvin102/svelte-nerdfonts.git
$ cd svelte-nerdfonts
$ npm run setup
svelte-nerdfonts uses icalvin102/nerdconvert
to generate the icons. This needs python
and fontforge
to be installed
on your machine.
If the dependencies are installed you can simply run:
npm run generate
or
python nerdconvert.py -o es icons/ --fields iconname paths viewbox
(see nerdconvert#usage for more details)