svelte simple icons
v4.0.1
Paket ini menyediakan Simple Icons 13.21.0 yang dikemas sebagai sekumpulan komponen Svelte.
Instal paket di direktori proyek Anda dengan:
// with yarn
yarn add @icons-pack/svelte-simple-icons
// with npm
npm add @icons-pack/svelte-simple-icons
Semua ikon diimpor dari satu file, di mana [ICON SLUG] diganti dengan slug berhuruf besar.
Edit kode dan kotak
<!-- Import a specific icon by its slug as: -->
<!-- import { Si[ICON SLUG] } from 'simple-icons'; -->
< script >
import { SiReact , SiSvelte , SiDocker } from " @icons-pack/svelte-simple-icons " ;
</ script >
< SiSvelte color = "#FF3E00" size ={ 90 } />
< SiReactJs color = "#61DAFB" size ={ 50 } />
< SiDocker />
<!-- title default "Svelte" -->
< script >
import { SiSvelte } from " @icons-pack/svelte-simple-icons " ;
</ script >
< SiSvelte title = " My title " />
< script >
import { SiSvelte } from " @icons-pack/svelte-simple-icons " ;
</ script >
< SiSvelte class = " myStyle " />
< style >
.myStyle {
width : 35 px ;
height : 35 px ;
}
</ style >
Terkadang, kita ingin menyediakan komponen secara dinamis ke suatu komponen. Kita dapat melakukannya dengan menggunakan fitur svelte:component
dengan definisi tipe pembantu tipe SiComponentType
.
< script lang = " ts " >
import type { SiComponentType } from ' @icons-pack/svelte-simple-icons ' ;
export let icon : SiComponentType ;
export let text : string ;
export let click : () => void = () => console . log ( ' do something ' );
</ script >
< button on:click ={ click }>
< svelte:component
this ={ icon }
title ={ text } <!-- optional , along with size and color properties -->
/>
{ text }
</ button >
< style lang = " scss " >
button {
display : flex ;
flex-direction : row ;
text-decoration : none ;
white-space : nowrap ;
transition : border-color 0.25 s ;
box-shadow : none ;
text-shadow : none ;
}
.icon {
margin : 4 px 4 px 0 0 ;
}
</ style >
Jika Anda hanya memerlukan beberapa ikon, Anda dapat mengimpornya satu per satu, bukan keseluruhan file untuk meningkatkan kompilasi.
< script >
import SiSvelte from " @icons-pack/svelte-simple-icons/icons/SiSvelte.svelte " ;
import SiGithub from " @icons-pack/svelte-simple-icons/icons/SiGithub.svelte " ;
</ script >
< SiGithub />
< SiSvelte />