Open In App

React Suite Icon extension Iconfont Icons

Last Updated : 27 Jul, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

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:

  • fill: It is used to fill icon color.
  • flip: It is used to flip icons.
  • icon: It uses the name from the iconfont icon set.
  • pulse: It uses pulse to have it rotate with eight steps.
  • rotate: It is used to rotate icons.
  • spin: It is used to spin icons.
  • style: It is used to change the style properties of icons, like fontSize and color.

createIconFont Props:

  • commonprops: It defines extra properties to the component.
  • scriptUrl: It uses the js URL generated online by icon font.cn, or you can use the local URL.

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.

Javascript




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.

Javascript




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



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads