How to use fontawesome in react?
I want use fontawesome in my react project, i read document and add fontawesome with yarn:
$ yarn add @fortawesome/fontawesome-svg-core
$ yarn add @fortawesome/free-solid-svg-icons
$ yarn add @fortawesome/react-fontawesome
and create a component like as below:
import React, { Component } from 'react';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
class Todo extends Component {
render() {
return (
<div>
font: <FontAwesomeIcon icon="coffee" />
</div>
);
}
}
export default Todo;
But don't show icon, how fix this?
javascript reactjs font-awesome
add a comment |
I want use fontawesome in my react project, i read document and add fontawesome with yarn:
$ yarn add @fortawesome/fontawesome-svg-core
$ yarn add @fortawesome/free-solid-svg-icons
$ yarn add @fortawesome/react-fontawesome
and create a component like as below:
import React, { Component } from 'react';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
class Todo extends Component {
render() {
return (
<div>
font: <FontAwesomeIcon icon="coffee" />
</div>
);
}
}
export default Todo;
But don't show icon, how fix this?
javascript reactjs font-awesome
You could have a look at this library too. react-icons.netlify.com/#
– dmraptis
Jan 18 at 16:17
add a comment |
I want use fontawesome in my react project, i read document and add fontawesome with yarn:
$ yarn add @fortawesome/fontawesome-svg-core
$ yarn add @fortawesome/free-solid-svg-icons
$ yarn add @fortawesome/react-fontawesome
and create a component like as below:
import React, { Component } from 'react';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
class Todo extends Component {
render() {
return (
<div>
font: <FontAwesomeIcon icon="coffee" />
</div>
);
}
}
export default Todo;
But don't show icon, how fix this?
javascript reactjs font-awesome
I want use fontawesome in my react project, i read document and add fontawesome with yarn:
$ yarn add @fortawesome/fontawesome-svg-core
$ yarn add @fortawesome/free-solid-svg-icons
$ yarn add @fortawesome/react-fontawesome
and create a component like as below:
import React, { Component } from 'react';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
class Todo extends Component {
render() {
return (
<div>
font: <FontAwesomeIcon icon="coffee" />
</div>
);
}
}
export default Todo;
But don't show icon, how fix this?
javascript reactjs font-awesome
javascript reactjs font-awesome
asked Jan 18 at 16:08
Masoud92mMasoud92m
1299
1299
You could have a look at this library too. react-icons.netlify.com/#
– dmraptis
Jan 18 at 16:17
add a comment |
You could have a look at this library too. react-icons.netlify.com/#
– dmraptis
Jan 18 at 16:17
You could have a look at this library too. react-icons.netlify.com/#
– dmraptis
Jan 18 at 16:17
You could have a look at this library too. react-icons.netlify.com/#
– dmraptis
Jan 18 at 16:17
add a comment |
4 Answers
4
active
oldest
votes
You seem to be missing some imports.
import { library } from '@fortawesome/fontawesome-svg-core'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faIgloo } from '@fortawesome/free-solid-svg-icons'
library.add(faIgloo)
https://fontawesome.com/how-to-use/on-the-web/using-with/react
add a comment |
If you want to reference the icon by its name you have to declare a library:
import ReactDOM from 'react-dom'
import { library } from '@fortawesome/fontawesome-svg-core'
import { fab } from '@fortawesome/free-brands-svg-icons'
import { faCheckSquare, faCoffee } from '@fortawesome/free-solid-svg-icons'
library.add(fab, faCheckSquare, faCoffee)
Then use it like this:
import React from 'react'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
export const Beverage = () => (
<div>
<FontAwesomeIcon icon="check-square" />
Favorite beverage: <FontAwesomeIcon icon="coffee" />
</div>
)
Otherwise, you can use explicit imports:
import ReactDOM from 'react-dom'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faCoffee } from '@fortawesome/free-solid-svg-icons'
const element = <FontAwesomeIcon icon={faCoffee} />
ReactDOM.render(element, document.body)
All this bits of details are explained here. The above examples are from there.
add a comment |
It could be that you are spelling 'fortawesome' and not 'fontawesome'
Oddly, that's how it's specified in the docs. fontawesome.com/how-to-use/on-the-web/using-with/react
– isherwood
Jan 18 at 16:11
@isherwood Weird, I didn't check the docs, just glanced over his code. I wonder why they did that
– remoo
Jan 18 at 16:12
IIRC fortawesome used to be their domain. Maybe before they got the big $ from the kickstarter
– engineerDave
Jan 18 at 16:23
add a comment |
Firstly you should use npm to install the react package
npm i -g yarn
yarn add react-native-fontawesome
After this you must import the data to start using in your project
import FontAwesome, { Icons } from 'react-native-fontawesome';
...
render() {
return (
<View>
<Text style={{margin: 10, fontSize: 15, textAlign: 'left'}}>
<FontAwesome>{Icons.chevronLeft}</FontAwesome>
Text
</Text>
</View>
);
},
if you want a more complete tutorial you can access the tutorial clicking here
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54257590%2fhow-to-use-fontawesome-in-react%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
You seem to be missing some imports.
import { library } from '@fortawesome/fontawesome-svg-core'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faIgloo } from '@fortawesome/free-solid-svg-icons'
library.add(faIgloo)
https://fontawesome.com/how-to-use/on-the-web/using-with/react
add a comment |
You seem to be missing some imports.
import { library } from '@fortawesome/fontawesome-svg-core'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faIgloo } from '@fortawesome/free-solid-svg-icons'
library.add(faIgloo)
https://fontawesome.com/how-to-use/on-the-web/using-with/react
add a comment |
You seem to be missing some imports.
import { library } from '@fortawesome/fontawesome-svg-core'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faIgloo } from '@fortawesome/free-solid-svg-icons'
library.add(faIgloo)
https://fontawesome.com/how-to-use/on-the-web/using-with/react
You seem to be missing some imports.
import { library } from '@fortawesome/fontawesome-svg-core'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faIgloo } from '@fortawesome/free-solid-svg-icons'
library.add(faIgloo)
https://fontawesome.com/how-to-use/on-the-web/using-with/react
answered Jan 18 at 16:15
isherwoodisherwood
36.8k1082111
36.8k1082111
add a comment |
add a comment |
If you want to reference the icon by its name you have to declare a library:
import ReactDOM from 'react-dom'
import { library } from '@fortawesome/fontawesome-svg-core'
import { fab } from '@fortawesome/free-brands-svg-icons'
import { faCheckSquare, faCoffee } from '@fortawesome/free-solid-svg-icons'
library.add(fab, faCheckSquare, faCoffee)
Then use it like this:
import React from 'react'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
export const Beverage = () => (
<div>
<FontAwesomeIcon icon="check-square" />
Favorite beverage: <FontAwesomeIcon icon="coffee" />
</div>
)
Otherwise, you can use explicit imports:
import ReactDOM from 'react-dom'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faCoffee } from '@fortawesome/free-solid-svg-icons'
const element = <FontAwesomeIcon icon={faCoffee} />
ReactDOM.render(element, document.body)
All this bits of details are explained here. The above examples are from there.
add a comment |
If you want to reference the icon by its name you have to declare a library:
import ReactDOM from 'react-dom'
import { library } from '@fortawesome/fontawesome-svg-core'
import { fab } from '@fortawesome/free-brands-svg-icons'
import { faCheckSquare, faCoffee } from '@fortawesome/free-solid-svg-icons'
library.add(fab, faCheckSquare, faCoffee)
Then use it like this:
import React from 'react'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
export const Beverage = () => (
<div>
<FontAwesomeIcon icon="check-square" />
Favorite beverage: <FontAwesomeIcon icon="coffee" />
</div>
)
Otherwise, you can use explicit imports:
import ReactDOM from 'react-dom'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faCoffee } from '@fortawesome/free-solid-svg-icons'
const element = <FontAwesomeIcon icon={faCoffee} />
ReactDOM.render(element, document.body)
All this bits of details are explained here. The above examples are from there.
add a comment |
If you want to reference the icon by its name you have to declare a library:
import ReactDOM from 'react-dom'
import { library } from '@fortawesome/fontawesome-svg-core'
import { fab } from '@fortawesome/free-brands-svg-icons'
import { faCheckSquare, faCoffee } from '@fortawesome/free-solid-svg-icons'
library.add(fab, faCheckSquare, faCoffee)
Then use it like this:
import React from 'react'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
export const Beverage = () => (
<div>
<FontAwesomeIcon icon="check-square" />
Favorite beverage: <FontAwesomeIcon icon="coffee" />
</div>
)
Otherwise, you can use explicit imports:
import ReactDOM from 'react-dom'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faCoffee } from '@fortawesome/free-solid-svg-icons'
const element = <FontAwesomeIcon icon={faCoffee} />
ReactDOM.render(element, document.body)
All this bits of details are explained here. The above examples are from there.
If you want to reference the icon by its name you have to declare a library:
import ReactDOM from 'react-dom'
import { library } from '@fortawesome/fontawesome-svg-core'
import { fab } from '@fortawesome/free-brands-svg-icons'
import { faCheckSquare, faCoffee } from '@fortawesome/free-solid-svg-icons'
library.add(fab, faCheckSquare, faCoffee)
Then use it like this:
import React from 'react'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
export const Beverage = () => (
<div>
<FontAwesomeIcon icon="check-square" />
Favorite beverage: <FontAwesomeIcon icon="coffee" />
</div>
)
Otherwise, you can use explicit imports:
import ReactDOM from 'react-dom'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faCoffee } from '@fortawesome/free-solid-svg-icons'
const element = <FontAwesomeIcon icon={faCoffee} />
ReactDOM.render(element, document.body)
All this bits of details are explained here. The above examples are from there.
answered Jan 18 at 16:17
GramatiikGramatiik
8710
8710
add a comment |
add a comment |
It could be that you are spelling 'fortawesome' and not 'fontawesome'
Oddly, that's how it's specified in the docs. fontawesome.com/how-to-use/on-the-web/using-with/react
– isherwood
Jan 18 at 16:11
@isherwood Weird, I didn't check the docs, just glanced over his code. I wonder why they did that
– remoo
Jan 18 at 16:12
IIRC fortawesome used to be their domain. Maybe before they got the big $ from the kickstarter
– engineerDave
Jan 18 at 16:23
add a comment |
It could be that you are spelling 'fortawesome' and not 'fontawesome'
Oddly, that's how it's specified in the docs. fontawesome.com/how-to-use/on-the-web/using-with/react
– isherwood
Jan 18 at 16:11
@isherwood Weird, I didn't check the docs, just glanced over his code. I wonder why they did that
– remoo
Jan 18 at 16:12
IIRC fortawesome used to be their domain. Maybe before they got the big $ from the kickstarter
– engineerDave
Jan 18 at 16:23
add a comment |
It could be that you are spelling 'fortawesome' and not 'fontawesome'
It could be that you are spelling 'fortawesome' and not 'fontawesome'
answered Jan 18 at 16:11
remooremoo
248
248
Oddly, that's how it's specified in the docs. fontawesome.com/how-to-use/on-the-web/using-with/react
– isherwood
Jan 18 at 16:11
@isherwood Weird, I didn't check the docs, just glanced over his code. I wonder why they did that
– remoo
Jan 18 at 16:12
IIRC fortawesome used to be their domain. Maybe before they got the big $ from the kickstarter
– engineerDave
Jan 18 at 16:23
add a comment |
Oddly, that's how it's specified in the docs. fontawesome.com/how-to-use/on-the-web/using-with/react
– isherwood
Jan 18 at 16:11
@isherwood Weird, I didn't check the docs, just glanced over his code. I wonder why they did that
– remoo
Jan 18 at 16:12
IIRC fortawesome used to be their domain. Maybe before they got the big $ from the kickstarter
– engineerDave
Jan 18 at 16:23
Oddly, that's how it's specified in the docs. fontawesome.com/how-to-use/on-the-web/using-with/react
– isherwood
Jan 18 at 16:11
Oddly, that's how it's specified in the docs. fontawesome.com/how-to-use/on-the-web/using-with/react
– isherwood
Jan 18 at 16:11
@isherwood Weird, I didn't check the docs, just glanced over his code. I wonder why they did that
– remoo
Jan 18 at 16:12
@isherwood Weird, I didn't check the docs, just glanced over his code. I wonder why they did that
– remoo
Jan 18 at 16:12
IIRC fortawesome used to be their domain. Maybe before they got the big $ from the kickstarter
– engineerDave
Jan 18 at 16:23
IIRC fortawesome used to be their domain. Maybe before they got the big $ from the kickstarter
– engineerDave
Jan 18 at 16:23
add a comment |
Firstly you should use npm to install the react package
npm i -g yarn
yarn add react-native-fontawesome
After this you must import the data to start using in your project
import FontAwesome, { Icons } from 'react-native-fontawesome';
...
render() {
return (
<View>
<Text style={{margin: 10, fontSize: 15, textAlign: 'left'}}>
<FontAwesome>{Icons.chevronLeft}</FontAwesome>
Text
</Text>
</View>
);
},
if you want a more complete tutorial you can access the tutorial clicking here
add a comment |
Firstly you should use npm to install the react package
npm i -g yarn
yarn add react-native-fontawesome
After this you must import the data to start using in your project
import FontAwesome, { Icons } from 'react-native-fontawesome';
...
render() {
return (
<View>
<Text style={{margin: 10, fontSize: 15, textAlign: 'left'}}>
<FontAwesome>{Icons.chevronLeft}</FontAwesome>
Text
</Text>
</View>
);
},
if you want a more complete tutorial you can access the tutorial clicking here
add a comment |
Firstly you should use npm to install the react package
npm i -g yarn
yarn add react-native-fontawesome
After this you must import the data to start using in your project
import FontAwesome, { Icons } from 'react-native-fontawesome';
...
render() {
return (
<View>
<Text style={{margin: 10, fontSize: 15, textAlign: 'left'}}>
<FontAwesome>{Icons.chevronLeft}</FontAwesome>
Text
</Text>
</View>
);
},
if you want a more complete tutorial you can access the tutorial clicking here
Firstly you should use npm to install the react package
npm i -g yarn
yarn add react-native-fontawesome
After this you must import the data to start using in your project
import FontAwesome, { Icons } from 'react-native-fontawesome';
...
render() {
return (
<View>
<Text style={{margin: 10, fontSize: 15, textAlign: 'left'}}>
<FontAwesome>{Icons.chevronLeft}</FontAwesome>
Text
</Text>
</View>
);
},
if you want a more complete tutorial you can access the tutorial clicking here
answered Jan 18 at 16:18
Super PenguinoSuper Penguino
1
1
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54257590%2fhow-to-use-fontawesome-in-react%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You could have a look at this library too. react-icons.netlify.com/#
– dmraptis
Jan 18 at 16:17