React Suite Icon extension
Last Updated :
28 Jul, 2022
React suite is a library of React components, sensible UI design, and a friendly development experience. It is supported in all major browsers. It provides pre-built components of React which can be used easily in any web application.
In this article, we’ll learn about React Suite Icon extension. For adding different icons instead of Rsuite Icons, the user can also use custom SVG icons, react icons, font awesome icons, and IconFont icons.
Syntax:
function App() {
return (
<div>
<Icon as={FaHome || SvgIcon} />
</div>
);
}
Using React Icons Component:
Step 1: Install the @rsuite/icons package into your project directory.
npm install --save @rsuite/icons
Step 2: Import the Icons in your function component from the package.
import { Icon } from '@rsuite/icons';
Step 3: Install React Icon package into your project.
npm install react-icons --save
Example 1: Below example demonstrates the use of FontAwesome Icons.
Javascript
import { Icon } from "@rsuite/icons" ;
import * as faFacebook from
"@fortawesome/free-brands-svg-icons/faFacebook" ;
import * as faGoogle from
"@fortawesome/free-brands-svg-icons/faGoogle" ;
import "rsuite/dist/rsuite.min.css" ;
function App() {
const FaSvgIcon = ({ faIcon, ...rest }) => {
const { width, height, svgPathData } = faIcon;
return (
<svg
{...rest}
viewBox={`0 0 ${width} ${height}`}
width= "5em"
height= "5em"
fill= "currentColor"
>
<path d={svgPathData}></path>
</svg>
);
};
return (
<div style={{ padding: 10, textAlign: 'center' }}>
<h2>GeeksforGeeks</h2>
<h4 style={{ color: "green" }}>
React Suite Icon Extension
</h4>
<div style={{ textAlign: 'center' }}>
<Icon as={FaSvgIcon} faIcon={faFacebook}
style={{ color: "blue" }} />
<Icon
as={FaSvgIcon}
faIcon={faGoogle}
style={{ color: "red" , marginLeft: 10 }}
/>
</div>
</div>
);
}
export default App;
|
Output:
Example 2: Below example demonstrates the use of React Icons.
Javascript
import { Icon } from "@rsuite/icons" ;
import "rsuite/dist/rsuite.min.css" ;
import { FaUndo as FaArrow } from 'react-icons/fa' ;
export default function App() {
return (
<div>
<div style={{ textAlign: "center" }}>
<h2>GeeksforGeeks</h2>
<h4 style={{ color: "green" }}>
React Suite Icon Extension
</h4>
</div>
<div
style={{
textAlign: "center" ,
padding: 20
}}
>
<Icon pulse as={FaArrow}
style={{ fontSize: 40 }} color= "green" />
<Icon
pulse
as={FaArrow}
style={{ fontSize: 30, marginLeft: 10 }}
color= "green"
/>
</div>
</div>
);
}
|
Output:
Reference: https://rsuitejs.com/components/icon/#icon-extension
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...