Open In App

React Suite Icon extension Iconfont Icons

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 Iconfont Icons. Iconfont icons are very popular icons that consist of various types of icons.



IconFont Props:

createIconFont Props:



Creating React Application And Installing Module:

Step 1: Create a React application using the given command:

npm create-react-app projectname

Step 2: After creating your project, move to it using the given command:

cd projectname

Step 3: Now Install the rsuite node package using the given command:

npm install rsuite

Project Structure: Now your project structure should look like the following:

 

Using 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';

Syntax:

import { createIconFont } from '@rsuite/icons';

const IconFont = createIconFont({
    scriptUrl: '//at.alicdn.com/t/font_2144422_r174s9i1orl.js',
    commonProps: { style: { color: 'red' } },
});

function App() {
    <IconFont icon="rs-iconemail" />
}

Example 1: Below example demonstrates the basic Iconfont Icon.




import "rsuite/dist/rsuite.min.css";
import { createIconFont } from '@rsuite/icons';
  
const IconFontIcons = createIconFont({
    scriptUrl: '//at.alicdn.com/t/font_2144422_r174s9i1orl.js',
    commonProps: {
        style: {
            fontSize: 40, marginRight: 10, color: 'green'
        }
    },
});
  
export default function App() {
    return (
        <center>
            <div>
                <h2>GeeksforGeeks</h2>
                <h4 style={{ color: "green" }}>
                    React Suite Icon Extension Iconfont Icons
                </h4>
  
                <div style={{ marginTop: 20, width: 400 }}>
                    <IconFontIcons icon="rs-iconrandom" />
                    <IconFontIcons icon="rs-iconrandom"
                                   flip="horizontal" />
                </div>
            </div>
        </center>
    );
}

Output:

 

Example 2: Below example demonstrates the fill and rotate props of IconFont component.




import "rsuite/dist/rsuite.min.css";
import { createIconFont } from '@rsuite/icons';
  
const IconFontIcons = createIconFont({
    scriptUrl: '//at.alicdn.com/t/font_2144422_r174s9i1orl.js',
    commonProps: {
        style: {
            fontSize: 40, marginRight: 10, color: 'red'
        }
    },
});
  
export default function App() {
    return (
        <center>
            <div>
                <h2>GeeksforGeeks</h2>
                <h4 style={{ color: "green" }}>
                    React Suite Icon Extension Iconfont Icons
                </h4>
  
                <div style={{ marginTop: 20, width: 400 }}>
                    <IconFontIcons icon="rs-icongrowth"
                                   fill="blue" />
                    <IconFontIcons icon="rs-icongrowth"
                                   rotate={'180'} />
                </div>
            </div>
        </center>
    );
}

Output:

 

Reference: https://rsuitejs.com/components/icon/#iconfont-icons


Article Tags :