svelte-svg-import
v1.6.0
Published
Use SVG images as Svelte components
Downloads
10
Readme
svelte-svg-import
Use SVG files as Svelte component
Usage
Add Vite plugin vite.config.js
:
import svelteSvgImport from 'svelte-svg-import';
export default defineConfig({
plugins: [
svelteSvgImport(),
sveltekit(),
],
});
Import SVG file with ?svelte
suffix to use it as component:
<script>
import Image from 'image.svg?svelte';
</script>
<Image width="20" height="20" />
For Typescript support add types for .svg to your project (e.g. to svg.d.ts
).