Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • Next.js Tutorial
  • Next.js Components
  • Next.js Functions
  • Next.js Deployment
  • Next.js Projects
  • Next.js Routing
  • Next.js Styles
  • Next.js Server-Side Rendering
  • Next.js Environment Variables
  • Next.js Middleware
  • Next.js Typescript
  • Next.js Image Optimization
  • Next.js Data Fetching
Open In App
Next Article:
How to use React Icons npm Package in React?
Next article icon

How to use React Icons in Next.js ?

Last Updated : 13 May, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

Icons make the website beautiful and interactive. Icons are an important part of a website's user interfaces, which are used in expressing objects, actions, and ideas. They are used to communicate the core idea and intent of a product or action and express the object visually. Here, we will learn to use React icons in Next JS applications.

Prerequisites:

  • NodeJS
  • NPM
  • NextJS

Approach to use React Icons in Next.js

  • Firstly, Install the react-icon package using the npm command.
  • This Next.js app imports the "FaBeer" icon from the "react-icons/fa" library.
  • Within the "Home" component, it displays a title "Using React Icons in NextJS" alongside the "FaBeer" icon.
  • Use Custom CSS for extra styling to the webpage.

Steps to Create the Next.js Application

Step 1: Create a Next application using the following command.

npx create-next-app@latest react-icon-nextapp

Step 2: After creating your project folder i.e. foldername, move to it using the following command:

cd react-icon-nextapp

Step 3: Install react icons in the folder

npm install react-icons --save

Project Structure:

The updated dependencies in package.json file will look like:

    "dependencies": {
"next": "14.2.3",
"react": "^18",
"react-dom": "^18",
"react-icons": "^5.2.0"
},

Example 1: The below example shows how to use react icons in a simple page.

CSS
.style_main{     background-color: black;     color: white;     text-align: center;     height: 100vh; } 
JavaScript
// Filename - page.js  import { FaBeer } from 'react-icons/fa'; import "./style.css"; export default function Home() {     return (         <main className="style_main">             <h1>GeeksForGeeks NextJS Concepts</h1>             <h3><b>Using React Icons in NextJS</b></h3>             <FaBeer /><br />         </main>     ); } 

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

npm run dev

Output:

Output

Example 2: The below example shows how to use react icons in a simple page with different font sizes to various react-icons.

CSS
.style_main{     background-color: black;     color: white;     text-align: center;     height: 100vh; } 
JavaScript
// Filename - page.js  import { FcCallTransfer, FcBarChart } from 'react-icons/fc'; import { Bs8CircleFill, BsAlarmFill } from "react-icons/bs";  export default function Home() {     return (         <main className=" style_main">              <h1>GeeksForGeeks NextJS Concepts</h1>             <h3><b>Using React Icons in NextJS</b></h3>             <FcCallTransfer fontSize={20} /><br />             <FcBarChart fontSize={30} /><br />             <BsAlarmFill fontSize={40} /> <br />             <Bs8CircleFill fontSize={45} />         </main>     ); } 

Output:

using react icons in next js

Example: The below example showsuse React icons in Next.js with additional style using CSS in your "style.css".

CSS
.myIconClass{     color: green;     background-color: yellow;  }  .style_main{     background-color: black;     color: white;     text-align: center;     height: 100vh; } 
JavaScript
import "./style.css";  import { FcCallTransfer, FcBarChart } from 'react-icons/fc'; import { Bs8CircleFill, BsAlarmFill } from "react-icons/bs";  export default function Home() {     return (         <main className="style_main">              <h1>GeeksForGeeks NextJS Concepts</h1>             <h3><b>Using React Icons in NextJS</b></h3>             <FcCallTransfer fontSize={20} /><br />             <FcBarChart fontSize={30} /><br />             <BsAlarmFill fontSize={40} /> <br />             <Bs8CircleFill fontSize={45} className="myIconClass" />         </main>     ); } 

Output:using react icon in next js example


Next Article
How to use React Icons npm Package in React?

G

geetanjali16
Improve
Article Tags :
  • Web Technologies
  • ReactJS
  • Next.js

Similar Reads

  • How to use Icon Component in React JS?
    Every application requires icons for UI purposes, and integrating them with Material UI for React is seamless. Utilize the Icon Component in ReactJS effortlessly by following this straightforward approach. Prerequisites:NodeJS or NPMReact JSMaterial UISteps to create React Application And Installing
    2 min read
  • How to use React Icons npm Package in React?
    The React Icons NPM package allows us to easily include popular icons in our React project. It provides a vast collection of icons from various icon libraries like Font Awesome, Material Design, and others wrapped in React Components. This enables us to seamlessly integrate these icons into our reac
    3 min read
  • How to Redirect in Next.js ?
    NextJS is a React framework that is used to build full-stack web applications. It is used both for front-end as well as back-end. It comes with a powerful set of features to simplify the development of React applications. In this article, we will learn about How to Redirect in NextJS with different
    4 min read
  • How to use Bootstrap Icons in React ?
    React is a free library for making websites look and feel cool. With React, your websites can be super interactive and lively. It’s great for making modern websites where everything happens on one page. The best part is that you can build and reuse different parts of your webpage, making it easy to
    2 min read
  • How to import SASS in Next.js ?
    Sass is the short form of Syntactically Awesome Style Sheet. It is an upgrade to Cascading Style Sheets (CSS). Sass is a CSS pre-processor. It is fully compatible with every version of CSS. Importing SASS in Next.js allows you to use SCSS for styling your application. This integration enables advanc
    2 min read
  • How to add Web Share in Next.js ?
    The Web Share API enables web applications to share content (like URLs, text, or files) to other apps installed on a user's device, such as social media platforms, messaging apps, or email clients. Integrating the Web Share API into a Next.js project enhances user experience by providing a seamless
    2 min read
  • How to use Link Component in React JS?
    Material-UI provides a set of components that can be seamlessly integrated with React to create visually appealing and functional navigation elements. The Link component allows you to easily customize anchor elements with our own theme colors and typography styles. Material UI for React has this com
    2 min read
  • How to use List Component in ReactJS?
    Lists are continuous, vertical indexes of text or images. Material UI for React has this component available for us, and it is very easy to integrate. We can use the List Component in ReactJS using the following approach. Prerequisites:NodeJS or NPMReactJSSteps to Create the React Application And In
    2 min read
  • How to Use the App Directory in Next.js?
    The App Directory in Next.js provides a powerful way to structure and manage your application's pages and components. It simplifies the routing and organization of your project, enabling you to build complex web applications with ease. Understanding the App DirectoryThe App Directory is a new struct
    3 min read
  • How to use Material UI Icons ?
    Material UI Icons is a library that provides a collection of pre-designed icons following Google's Material Design guidelines. These icons can be easily integrated into React applications to enhance visual elements and improve user experience. Installation// Package containing Material UI icon compo
    1 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences