mirror of
https://github.com/lucide-icons/lucide.git
synced 2025-12-22 14:29:22 +01:00
* init svelte project * Add export script for lucide-svelte * make lucide-svelte wokring * make ready for first release * update lock file * bump version * some fixes in the build * Add tests * Finish tests * Update Readme * update lock file * Add svelte to gh actions * Add svetle to website docs * Add test ci script * adjust action * add on PR trigger * remove dep * fix tests * Add svelte entry in package.json * update snapshots
1.8 KiB
1.8 KiB
Lucide Svelte
Implementation of the lucide icon library for svelte applications.
Installation
yarn add lucide-svelte
# or
npm install lucide-svelte
How to use
All the icons are Svelte components, that ouputs Svg elements. So each icon can be imported and used as a component. This also helps with the use of threeshaking so you only import the icons you use.
Example
Default usage:
<script>
import { Skull } from 'lucide-svelte'
</script>
<Skull/>
You can pass additional props to adjust the icon.
<script>
import { Camera } from 'lucide-svelte'
</script>
<Camera />
Available props
| name | type | default |
|---|---|---|
size |
Number | 24 |
color |
String | currentColor |
strokeWidth |
Number | 2 |
*<SVGProps> |
String | - |
* All SVGProps are available to style the svgs. See the list of SVG Presentation Attributes on MDN
Example of custom props
<script>
import { Phone } from 'lucide-svelte'
</script>
<Phone fill="#333"/>
This results a filled phone icon.
One generic icon component
It is possible to create one generic icon component to load icons.
⚠️ Example below importing all EsModules, caution using this example, not recommended when you bundle your application,the build size will grow strongly. Because it will import all the icons.
Icon Component Example
<script>
import * as icons from "lucide-svelte";
export let name;
</script>
<svelte:component this={icons[name]} {...$$props}/>
Then you can use it like this
<script>
import LucideIcon from "./LucideIcon";
</script>
<LucideIcon name="Menu" />