Home

Awesome

svelte-fa

npm bundle size npm downloads license

github build coverage

Tiny FontAwesome component for Svelte.

Documents and examples.

Installation

npm install svelte-fa

Install FontAwesome icons via official packages, for example:

npm install @fortawesome/free-solid-svg-icons
npm install @fortawesome/free-brands-svg-icons

Icons gallery: FontAwesome icons

Work with Sapper

You may need to install the component as a devDependency:

npm install svelte-fa -D

Work with SvelteKit/Vite

You may need to import the component explicitly as below:

import Fa from 'svelte-fa/dist/fa.svelte'
import { faCaretDown, faCaretUp } from '@fortawesome/free-solid-svg-icons/index.es'

When using typescript with SvelteKit/Vite, you may also needed to add type definitions that redirect to the non-index.es export:

// app.d.ts
declare module '@fortawesome/pro-solid-svg-icons/index.es' {
  export * from '@fortawesome/pro-solid-svg-icons';
}

Usage

<script>
import Fa from 'svelte-fa'
import { faFlag } from '@fortawesome/free-solid-svg-icons'
import { faGithub } from '@fortawesome/free-brands-svg-icons';
</script>

<Fa icon={faFlag} />
<Fa icon={faGithub} />

Fa Properties

<Fa
  icon={faFlag}
  class="bg-gold"
  size="2x"
  color="#ff0000"
  fw
  pull="left"
  scale={1.2}
  translateX={0.2}
  translateY={0.2}
  rotate={90}
  flip="horizontal"
  spin
  pulse
/>

Layering & Text

import Fa, {
  FaLayers,
  FaLayersText,
} from 'svelte-fa';
<FaLayers
  size="4x"
  pull="left"
>
  <Fa icon={faCertificate} />
  <FaLayersText
    scale={0.25}
    rotate={-30}
    color="white"
    style="font-weight: 900"
  >
    NEW
  </FaLayersText>
</FaLayers>

FaLayers Properties

FaLayersText Properties

Duotone Icons

<script>
import Fa from 'svelte-fa'
import { faFlag } from '@fortawesome/pro-duotone-svg-icons'
</script>

<Fa
  icon={faFlag}
  primaryColor="red"
  secondaryColor="#000000"
  primaryOpacity={0.8}
  secondaryOpacity={0.6}
  swapOpacity
/>

Duotone Icons Theme

<script>
import Fa from 'svelte-fa'
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}
/>

Contributors

<!-- readme: collaborators,contributors -start --> <table> <tr> <td align="center"> <a href="https://github.com/Cweili"> <img src="https://avatars.githubusercontent.com/u/2128450?v=4" width="100;" alt="Cweili"/> <br /> <sub><b>Cweili</b></sub> </a> </td> <td align="center"> <a href="https://github.com/marekdedic"> <img src="https://avatars.githubusercontent.com/u/3134692?v=4" width="100;" alt="marekdedic"/> <br /> <sub><b>Marek Dědič</b></sub> </a> </td> <td align="center"> <a href="https://github.com/gtm-nayan"> <img src="https://avatars.githubusercontent.com/u/50981692?v=4" width="100;" alt="gtm-nayan"/> <br /> <sub><b>Gtmnayan</b></sub> </a> </td> <td align="center"> <a href="https://github.com/ItzaMi"> <img src="https://avatars.githubusercontent.com/u/30603437?v=4" width="100;" alt="ItzaMi"/> <br /> <sub><b>Rui Sousa</b></sub> </a> </td> <td align="center"> <a href="https://github.com/theodorejb"> <img src="https://avatars.githubusercontent.com/u/3053271?v=4" width="100;" alt="theodorejb"/> <br /> <sub><b>Theodore Brown</b></sub> </a> </td> <td align="center"> <a href="https://github.com/msanguineti"> <img src="https://avatars.githubusercontent.com/u/19243840?v=4" width="100;" alt="msanguineti"/> <br /> <sub><b>Mirco Sanguineti</b></sub> </a> </td></tr> <tr> <td align="center"> <a href="https://github.com/RealA10N"> <img src="https://avatars.githubusercontent.com/u/23400213?v=4" width="100;" alt="RealA10N"/> <br /> <sub><b>Alon Krymgand</b></sub> </a> </td> <td align="center"> <a href="https://github.com/connercsbn"> <img src="https://avatars.githubusercontent.com/u/65339198?v=4" width="100;" alt="connercsbn"/> <br /> <sub><b>Conner</b></sub> </a> </td> <td align="center"> <a href="https://github.com/prokawsar"> <img src="https://avatars.githubusercontent.com/u/9526172?v=4" width="100;" alt="prokawsar"/> <br /> <sub><b>Kawsar Ahmed</b></sub> </a> </td> <td align="center"> <a href="https://github.com/mvolkmann"> <img src="https://avatars.githubusercontent.com/u/79312?v=4" width="100;" alt="mvolkmann"/> <br /> <sub><b>Mark Volkmann</b></sub> </a> </td> <td align="center"> <a href="https://github.com/ModischFabrications"> <img src="https://avatars.githubusercontent.com/u/25404728?v=4" width="100;" alt="ModischFabrications"/> <br /> <sub><b>Robin Modisch</b></sub> </a> </td> <td align="center"> <a href="https://github.com/RemiKalbe"> <img src="https://avatars.githubusercontent.com/u/8604600?v=4" width="100;" alt="RemiKalbe"/> <br /> <sub><b>Rémi Kalbe</b></sub> </a> </td></tr> <tr> <td align="center"> <a href="https://github.com/hawk93"> <img src="https://avatars.githubusercontent.com/u/3786547?v=4" width="100;" alt="hawk93"/> <br /> <sub><b>Null</b></sub> </a> </td></tr> </table> <!-- readme: collaborators,contributors -end -->