Tiny FontAwesome 5 component for Svelte with TypeScript types.
- FontAwesome svg icons
- Tree-shakable, only import used icons
- No CSS file required
- FontAwesome duotone icons
- TypeScript types
This library is derived from svelte-fa and can be used as a drop-in replacement for it. I did try to fix the original library but it was more work than to actually start anew (old rollupjs plugins, old deps, babel...)
So, I moved the code to TypeScript, dropped everything else (all the build tools), wrote a .d.ts
file and created this package.
Now the library works flawlessly when using <script lang="ts">
.
I am, of course, in debt to 👏 @Cweili 👏 and its work on the original library. 🎉 🎉 🎉
npm install svelte-fa-ts
Notice: For Sapper user, you have to install the component as a devDependency.
npm install svelte-fa-ts -D
<!-- <script lang="ts"> if using TypeScript -->
<script>
import Fa from 'svelte-fa-ts'
import { faFlag } from '@fortawesome/free-solid-svg-icons'
</script>
<Fa icon="{faFlag}" />
<Fa
icon="{faFlag}"
fw
flip="horizontal"
pull="left"
rotate="{90}"
size="2x"
color="#ff0000"
/>
fw
: fixed widthflip
:string
valueshorizontal
,vertical
,both
pull
:string
valuesleft
,right
rotate
:number or string
values90
,180
,270
,30
,-30
...size
:string
valuesxs
,sm
,lg
or2x
,3x
,4x
...color
: icon color, defaultcurrentColor
<Fa id="css_id" class="css_class" style="{color: #000;}" />
a font-awesome subscription is needed to download the
pro
version of the icons!
<script>
import Fa from 'svelte-fa-ts'
import { faFlag } from '@fortawesome/pro-duotone-svg-icons'
</script>
<Fa
icon="{faFlag}"
primaryColor="red"
secondaryColor="#000000"
primaryOpacity="{0.8}"
secondaryOpacity="{0.6}"
swapOpacity
/>
<script>
import Fa from 'svelte-fa-ts'
import { faFlag } from '@fortawesome/pro-duotone-svg-icons'
const theme = {
primaryColor: 'red',
secondaryColor: '#000000',
primaryOpacity: 0.8,
secondaryOpacity: 0.6,
}
</script>
<Fa icon="{faFlag}" {...theme} />