Open In App

React Suite Icon <IconFont> Props

Improve
Improve
Like Article
Like
Save
Share
Report

React Suite is a popular front-end library with a set of React components that are designed for the middle platform and back-end products.

There is a lot of data that gets rendered on a web page. Sometimes we require to represent data using icons. This is when the Icon component allows the user to add icons to your application. Icons are commonly used in every application for UI purposes.

React Suite Icon <IconFont> Props:

  • fill: It is used to fill the icon with a specific color.
  • icon: It is used to denote the icon name.
  • flip: It is used to flip the icon.
  • pulse: We can use pulse to have it rotate with 8 steps. It takes a boolean value.
  • rotate: It is used to rotate the icon.
  • spin: It is used for the dynamic rotation icon. It takes a boolean value.
  • style: It is used to set font size or color properties of icons.

Syntax:

<IconFont icon="rs-iconemail-fill" 
          flip="..." fill="..." 
          rotate={...} spin />

Approach: Let us create a React project and install React Suite module. Then we will create a UI that will showcase React Suite IconFont Props.

Creating React Project:

Step 1: To create a react app, you need to install react modules through npx command. “npx” is used instead of “npm” because you will need this command in your app’s lifecycle only once.

npx create-react-app project_name

Step 2: After creating your react project, move into the folder to perform different operations.

cd project_name

Step 3: After creating the ReactJS application, Install the required module using the following command:

npm install rsuite

Project Structure: It will look like this:

Project Structure

Example 1: We are creating a UI that shows different React Suite IconFont props.

App.js




import React from 'react'
import '../node_modules/rsuite/dist/rsuite.min.css';
import { createIconFont } from '@rsuite/icons';
  
export default function App() {
  
    const IconFont = createIconFont({
        scriptUrl: '//at.alicdn.com/t/font_2144422_r174s9i1orl.js',
        commonProps: { style: { fontSize: '5em', margin: '2%' } },
    });
  
    return (
        <div style={{ margin: 100 }}>
            <h1 style={{ color: 'green' }}>
                GeeksforGeeks
            </h1>
            <h1>
                React Suite IconFont Props
            </h1>
            <IconFont icon="rs-iconemail-fill" 
                      fill="green" />
            <IconFont icon="rs-iconemail-fill" 
                      rotate={90} fill="green" />
            <IconFont icon="rs-iconemail-fill" 
                      flip="vertical" fill="green" />
            <IconFont icon="rs-iconemail-fill" 
                      rotate={270} fill="green" />
        </div>
    );
}


Step to Run Application: Run the application using the following command from the root directory of the project:

npm start

Output: Now open your browser and go to http://localhost:3000/, you will see the following output:

React suite IconFont

Example 2: We are creating a UI that shows React Suite IconFont props.

App.js




import React from 'react'
import '../node_modules/rsuite/dist/rsuite.min.css';
import { createIconFont } from '@rsuite/icons';
  
export default function App() {
  
    const IconFont = createIconFont({
        scriptUrl: '//at.alicdn.com/t/font_2144422_r174s9i1orl.js',
        commonProps: { style: { fontSize: '5em', margin: '2%' } },
    });
  
    return (
        <div style={{ margin: 100 }}>
            <h1 style={{ color: 'green' }}>
                GeeksforGeeks
            </h1>
            <h1>
                React Suite IconFont Props
            </h1>
            <p>
                Normal Icon
                <IconFont icon="rs-iconreload" 
                    fill="green" />
            </p>
            <p>
                Icon with pulse prop
                <IconFont icon="rs-iconreload" 
                    pulse fill="green" />
            </p>
            <p>
                Icon with spin prop
                <IconFont icon="rs-iconreload" 
                    spin fill="green" />
            </p>
        </div>
    );
}


Output: Now open your browser and go to http://localhost:3000/, you will see the following output:

React suite IconFont

Reference: https://rsuitejs.com/components/icon/#code-lt-icon-font-gt-code



Last Updated : 05 Jul, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads