An warware: amsa font mai ban mamaki

React Font Awesome dole ne a sani ga kowane mai haษ“aka gaba-gaba ฦ™wararren React. Wannan fakitin yana ba ku gumaka masu sikeli waษ—anda za a iya keษ“ance su - girman, launi, faษ—uwar inuwa, da sauransu tare da ikon CSS. Duk waษ—annan gumaka masu ban sha'awa an haษ—a su a cikin abin ban mamaki mai sauฦ™in amfani da React don app ษ—in ku.

Matsalar Hannu

Sau da yawa, haษ—a dakunan karatu na gumaka cikin aikace-aikacen React na iya haifar da batutuwan aiki da rikitattun saiti saboda haษ—a dukkan gumaka, ba tare da la'akari da amfani ba. Anan shine React Font Awesome yana haskakawa. Yana ba mu damar shigo da gumakan da ake buฦ™ata kawai a cikin aikinmu, yana sa aikace-aikacen mu ya yi aiki.

Magani tare da React Font Awesome

Da farko, shigar da Font Awesome da fakitin da suka dace a cikin Ayyukan React ษ—inku ta amfani da umarni mai zuwa:

npm i --save @fortawesome/fontawesome-svg-core
npm i --save @fortawesome/free-solid-svg-icons
npm i --save @fortawesome/react-fontawesome

Yanzu kuna shirye don amfani da gumaka tare da waษ—annan layin lambar:

import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faCoffee } from '@fortawesome/free-solid-svg-icons'

const element = <FontAwesomeIcon icon={faCoffee} />

Lambar tana shigo da bangaren FontAwesomeIcon da gunkin kofi kuma yana amfani da su a bangaren React.

Bayanin mataki-mataki

Bari mu bincika yadda wannan ke aiki. Layin farko yana shigo da bangaren FontAwesomeIcon daga ษ—akin karatu na amsa-fontawesome. "FontAwesomeIcon" wani bangare ne kawai wanda Font Awesome ke bayarwa don amfani a cikin abubuwan da aka gyara na React. Layi na gaba yana shigo da gunki guda ษ—aya (

  • kafi

) daga fakitin-m-svg-gumakan kyauta. A ฦ™arshe, kuna amfani da gumakan da aka shigo da su azaman abin dogaro ga bangaren FontAwesomeIcon.

ฦ˜ari Game da Dakunan karatu na FontAwesome

Kunshin @fortawesome/fontawesome-svg-core shine ainihin Font Awesome. Ya ฦ™unshi salo da ayyukan tsarin SVG kuma yakamata a haษ—a su sau ษ—aya a kowane aiki.

The @fortawesome/free-solid-svg-gumakan kunshin ya ฦ™unshi duk waษ—annan gumaka masu ฦ™arfi kyauta waษ—anda galibi za ku yi amfani da su a cikin rukunin yanar gizonku/app. Hakanan ana samun sauran ษ—akunan karatu kamar na yau da kullun da samfuran iri.

The @fortawesome/react-fontawesome kunshin babban ษ—akin karatu ne don kawo FontAwesome cikin React ba tare da matsala ba.

React Font Awesome ya tabbatar da zama ingantaccen bayani don aiwatar da gumaka a cikin aikace-aikacen React yayin kiyaye aikace-aikacen ingantaccen kuma madaidaiciya.

Shafi posts:

Leave a Comment