How To Use Semantic UI Icons And Flags In ReactJS

Introduction

 
In this article we will learn about semantic UI Icons and flags. Semantic UI is a UI component framework for building resposive user interfaces. In previous articles we learned how to install semantic UI in React and basic components of Semantic UI.
 
You can check my previous articles from the below links,
Prerequisites
  • We should have a basic knowledge of HTML and ReactJS.
  • Visual Studio Code installed
  • Node and NPM installed
Step 1
 
Let's create a new React project by using the following command:
  1. npx create-react-app semanticuidemo  
Open this project in Visual Studio Code and install semantic UI using the following command.
  1. npm install semantic-ui-react   
Now open index.js file and import semantic UI css.
  1. import 'semantic-ui-css/semantic.min.css'  
Now go to src folder and create a new component 'IconsDemo.js'. Add the following code in this component:
  1. import React, { Component } from 'react'  
  2.   
  3. export class IconsDemo extends Component {  
  4.     render() {  
  5.         return (  
  6.             <div>  
  7.                 <div class="ui blue inverted three item menu">  
  8.                     <a class="item">Semantic UI Icons</a>  
  9.                 </div>  
  10.                 <div>  
  11.                     <i class="audio description icon"></i>  
  12.                     <i class="blind icon"></i>  
  13.                     <i class="braille icon"></i>  
  14.                     <i class="closed captioning icon"></i>  
  15.                     <i class="closed captioning outline icon"></i>  
  16.                     <i class="deaf icon"></i>  
  17.                     <i class="low vision icon"></i>  
  18.                     <i class="phone volume icon"></i>  
  19.                     <i class="question circle icon"></i>  
  20.                     <i class="question circle outline icon"></i>  
  21.                     <i class="sign language icon"></i>  
  22.                     <i class="tty icon"></i>  
  23.                 </div>  
  24.                 <div>  
  25.                     <i class="angle double down icon"></i>  
  26.                     <i class="angle double left icon"></i>  
  27.                     <i class="angle double right icon"></i>  
  28.                     <i class="angle double up icon"></i>  
  29.                     <i class="angle down icon"></i>  
  30.                     <i class="angle left icon"></i>  
  31.                     <i class="angle right icon"></i>  
  32.                     <i class="angle up icon"></i>  
  33.                     <i class="arrow alternate circle up icon"></i>  
  34.                     <i class="arrow alternate circle up outline icon"></i>  
  35.                     <i class="arrow circle down icon"></i>  
  36.                     <i class="arrow circle left icon"></i>  
  37.                     <i class="arrow circle right icon"></i>  
  38.                     <i class="arrow circle up icon"></i>  
  39.                     <i class="arrow down icon"></i>  
  40.                     <i class="arrow left icon"></i>  
  41.                     <i class="arrow right icon"></i>  
  42.                     <i class="arrow up icon"></i>  
  43.                     <i class="arrows alternate icon"></i>  
  44.                     <i class="arrows alternate horizontal icon"></i>  
  45.                     <i class="arrows alternate vertical icon"></i>  
  46.                     <i class="caret down icon"></i>  
  47.                     <i class="caret left icon"></i>  
  48.                     <i class="caret right icon"></i>  
  49.                     <i class="caret square down icon"></i>  
  50.                     <i class="caret square down outline icon"></i>  
  51.                     <i class="caret square left icon"></i>  
  52.                     <i class="caret square left outline icon"></i>  
  53.                     <i class="caret square right icon"></i>  
  54.                     <i class="caret square right outline icon"></i>  
  55.                     <i class="caret square up icon"></i>  
  56.                     <i class="caret square up outline icon"></i>  
  57.                     <i class="caret up icon"></i>  
  58.                     <i class="cart arrow down icon"></i>  
  59.                     <i class="chart line icon"></i>  
  60.                     <i class="chevron circle down icon"></i>  
  61.                     <i class="chevron circle left icon"></i>  
  62.                     <i class="chevron circle right icon"></i>  
  63.                     <i class="chevron circle up icon"></i>  
  64.                     <i class="chevron down icon"></i>  
  65.                     <i class="chevron left icon"></i>  
  66.                     <i class="chevron right icon"></i>  
  67.                     <i class="chevron up icon"></i>  
  68.                     <i class="cloud download icon"></i>  
  69.                     <i class="cloud upload icon"></i>  
  70.                     <i class="download icon"></i>  
  71.                     <i class="exchange alternate icon"></i>  
  72.                     <i class="expand arrows alternate icon"></i>  
  73.                     <i class="external alternate icon"></i>  
  74.                     <i class="external square alternate icon"></i>  
  75.                     <i class="hand point down icon"></i>  
  76.                     <i class="hand point down outline icon"></i>  
  77.                     <i class="hand point left icon"></i>  
  78.                     <i class="hand point left outline icon"></i>  
  79.                     <i class="hand point right icon"></i>  
  80.                     <i class="hand point right outline icon"></i>  
  81.                     <i class="hand point up icon"></i>  
  82.                     <i class="hand point up outline icon"></i>  
  83.                     <i class="hand pointer icon"></i>  
  84.                     <i class="hand pointer outline icon"></i>  
  85.                     <i class="history icon"></i>  
  86.                     <i class="level down alternate icon"></i>  
  87.                     <i class="level up alternate icon"></i>  
  88.                     <i class="location arrow icon"></i>  
  89.                     <i class="long arrow alternate down icon"></i>  
  90.                     <i class="long arrow alternate left icon"></i>  
  91.                     <i class="long arrow alternate right icon"></i>  
  92.                     <i class="long arrow alternate up icon"></i>  
  93.                     <i class="mouse pointer icon"></i>  
  94.                     <i class="play icon"></i>  
  95.                     <i class="random icon"></i>  
  96.                     <i class="recycle icon"></i>  
  97.                     <i class="redo icon"></i>  
  98.                     <i class="redo alternate icon"></i>  
  99.                     <i class="reply icon"></i>  
  100.                     <i class="reply all icon"></i>  
  101.                     <i class="retweet icon"></i>  
  102.                     <i class="share icon"></i>  
  103.                     <i class="share square icon"></i>  
  104.                     <i class="share square outline icon"></i>  
  105.                     <i class="sign in alternate icon"></i>  
  106.                     <i class="sign out alternate icon"></i>  
  107.                     <i class="sort icon"></i>  
  108.                     <i class="sort alphabet down icon"></i>  
  109.                     <i class="sort alphabet up icon"></i>  
  110.                     <i class="sort amount down icon"></i>  
  111.                     <i class="sort amount up icon"></i>  
  112.                     <i class="sort down icon"></i>  
  113.                     <i class="sort numeric down icon"></i>  
  114.                     <i class="sort numeric up icon"></i>  
  115.                     <i class="sort up icon"></i>  
  116.                     <i class="sync icon"></i>  
  117.                     <i class="sync alternate icon"></i>  
  118.                     <i class="text height icon"></i>  
  119.                      
  120.                 </div>  
  121.             </div>  
  122.         )  
  123.     }  
  124. }  
  125.   
  126. export default IconsDemo  
 Open the App.js file and add the folllowing code.
  1. import React from 'react';  
  2. import logo from './logo.svg';  
  3. import './App.css';  
  4. import IconsDemo from './IconsDemo'  
  5. function App() {  
  6.   return (  
  7.     <div className="App">  
  8.    <IconsDemo/>  
  9.     </div>  
  10.   );  
  11. }  
  12. export default App;  
Now, run the project by using 'npm start' command and check the result.
 
Now go to src folder and create a new component 'FlagsDemo.js'. Add the following code in this component,
  1. import React, { Component } from 'react'  
  2. export class FlagsDemo extends Component {  
  3.     render() {  
  4.         return (  
  5.             <div>  
  6.                 <div class="ui blue inverted three item menu">  
  7.                     <a class="item">Semantic UI Flag</a>  
  8.                 </div>  
  9.                 <div>  
  10.                     <i class="in flag"></i>  
  11.                     <i class="us flag"></i>  
  12.                     <i class="de flag"></i>  
  13.                     <i class="ae flag"></i>  
  14.                 </div>  
  15.             </div>  
  16.         )  
  17.     }  
  18. }  
  19.   
  20. export default FlagsDemo  
Open the App.js file and add the folllowing code.
  1. import React from 'react';  
  2. import logo from './logo.svg';  
  3. import './App.css';  
  4. import FlagsDemo from './FlagsDemo'  
  5. function App() {  
  6.   return (  
  7.     <div className="App">  
  8.    <FlagsDemo/>  
  9.     </div>  
  10.   );  
  11. }  
  12.   
  13. export default App;  
Now, run the project by using 'npm start' command and check the result. 

Summary

 
In this article, we learned about semantic UI Icons and flags and Semantic UI in a React.js application.