MUI Icons in React | refine (2023)


React is the most commonly used frontend framework for creating a responsive web interface. It is accompanied by libraries that provide elements with a means of working together to maximise the aesthetic value of any web design layout effectively. Some of these libraries include Material UI, Ant Design, React-Bootstrap, Semantic UI, Fluent UI, Blueprint UI, e.t.c.

These libraries, whether component or utility-based, perform specific roles in aiding React developers to create web structures that are responsive and pretty. For this article, we will focus on Material UI, investigate its icons and highlight their functions in a React application.

Steps we’ll cover:

  • What is Material UI?
  • Getting started with Material UI icons in React
  • How to apply MUI icons to your project
  • SvgIcon API
  • The Icon component(Font icons)
  • Building a Task Tracker with React and Material UI
  • Testing MUI Icons


To properly understand the scope of this article, you must have:

  • Thorough knowledge of HTML, CSS, and JavaScript
  • A working installation of Node.Js

What is Material UI?

Material UI is an open-source React component library based on Google’s Material Design. It provides a complete set of UI tools to help developers build and maintain React applications and effectively import components into several parts of their projects. Over the years, more developers have incorporated Material UI into their project UI because it makes the web design process significantly easier and faster.

Material UI offers components that can serve specific purposes on a web page. Some of which include Form components, Data display components, Feedback components, Navigation components, Layout components, e.t.c. Material UI icons are a significant example of the Data display components.

Getting started with Material UI icons in React

Material UI icons are a pre-made set of icons that can be extracted from the MUI component system and embedded into any React application. They are commonly used in application toolbars to represent frequent operations and actions. These icons make it easier for developers to create shortcuts on the app and substitute lengthy text descriptions with easy-to-understand representations.

MUI offers three types of icon support:

  • Uniform Material Icons that are exported as React Components
  • The SvgIcon component - A React wrapper for custom SVG icons.
  • The Icon component - A React wrapper for custom font icons.

How to apply MUI icons to your project

Step 1 - Install the MUI Library

Install the MUI library into your project as part of your package.json dependencies with the following command:

  • use npm
  • use yarn
npm install @mui/material @emotion/react @emotion/styled

Step 2 - Install the MUI Icons package

Install the MUI icons themselves into your project with the following command:

  • use npm
  • use yarn
npm install @mui/icons-material

You should now see the updated dependencies on your package.json like this:

(Video) How To Use Material UI Icons In React | Complete Tutorial

MUI Icons in React | refine (1)

Step 3 - Import the Icons

The next step would be to import the Material UI icons into your desired project directory by using one of the following techniques:

You can import each icon you intend to use for that particular React component individually like this:

import ArrowRight from '@mui/icons-material/ArrowRight'
import Camera from '@mui/icons-material/Camera'

You can import them together in one declaration like this:

import { ArrowRight, Camera } from '@mui/icons-material'

Each Material UI icon comes with a theme:

  • Filled(The default theme)
  • Outlined
  • Rounded
  • Two-tone
  • Sharp

To use a theme other than the default, append the theme name to the icon name when importing it. For instance, you can import a Camera icon with an outlined theme like this:


Step 4 - Displaying the icon on the DOM

After successfully installing the MUI library and icons package into your application, you can call the individual icons into your JSX as a component and export them into App.js, ensuring that they are displayed on the virtual DOM.

For instance, if you want to display Camera icons bearing all the primary themes. You can do that with the code below:

import React from "react";
import Grid from "@mui/material/Grid";
import Typography from "@mui/material/Typography";
import CameraIcon from "@mui/icons-material/Camera";
import CameraOutlinedIcon from "@mui/icons-material/CameraOutlined";
import CameraRoundedIcon from "@mui/icons-material/CameraRounded";
import CameraTwoToneIcon from "@mui/icons-material/CameraTwoTone";
import CameraSharpIcon from "@mui/icons-material/CameraSharp";
import ThreeSixtyIcon from "@mui/icons-material/ThreeSixty";

const Home = () => {
return (
<Grid container sx={{ color: "text.primary" }}>
<Grid item xs={4}>
<Grid item xs={8}>
<CameraIcon />
<Grid item xs={4}>
<Grid item xs={8}>
<CameraOutlinedIcon />
<Grid item xs={4}>
<Grid item xs={8}>
<CameraRoundedIcon />
<Grid item xs={4}>
<Typography>Two Tone</Typography>
<Grid item xs={8}>
<CameraTwoToneIcon />
<Grid item xs={4}>
<Grid item xs={8}>
<CameraSharpIcon />
<Grid item xs={4}>
<Grid item xs={8}>
<ThreeSixtyIcon />

export default Home;

The code above demonstrates how to include the Camera icon and its primary themes in a standard React project. The icons are then displayed as virtual DOM components.

Here’s the result:

MUI Icons in React | refine (2)

Small dev teams love this React framework!

(Video) #22. How to use Material UI icons in React.

Meet the headless, React-based solution to build sleek CRUD

applications. With refine, you can be confident that your codebase will always stay clean and boilerplate-free.



to rapidly build your next CRUD project, whether


an admin panel, dashboard, internal tool or storefront.

MUI Icons in React | refine (3)

SvgIcon API

For cases where you may need a custom SVG icon that is not readily available in the Material icon specifications, you can use the SvgIcon wrapper. This component is an extension of the native <svg> element:

  • It has built-in accessibility.
  • SVG elements have a default viewport size of 24px by 24px that can customised with the viewport attribute.
  • The component inherits the current colour by default. You can, at your discretion, use the color prop to apply one of the theme colours.

Below is a simple representation of how to call a customised MUI SvgIcon component:

import React from 'react';
import SvgIcon from '@mui/material/SvgIcon';
import CameraIcon from './Components/CameraIcon'

const HomeIcon = (props) => {
return (
<SvgIcon {...props}>
<path d="M9.4 10.5l4.77-8.26C13.47 2.09 12.75 2 12 2c-2.4 0-4.6.85-6.32 2.25l3.66 6.35.06-.1zM21.54 9c-.92-2.92-3.15-5.26-6-6.34L11.88 9h9.66zm.26 1h-7.49l.29.5 4.76 8.25C21 16.97 22 14.61 22 12c0-.69-.07-1.35-.2-2zM8.54 12l-3.9-6.75C3.01 7.03 2 9.39 2 12c0 .69.07 1.35.2 2h7.49l-1.15-2zm-6.08 3c.92 2.92 3.15 5.26 6 6.34L12.12 15H2.46zm11.27 0l-3.9 6.76c.7.15 1.42.24 2.17.24 2.4 0 4.6-.85 6.32-2.25l-3.66-6.35-.93 1.6z"/>

// And the code for the color setting would look the following way:
<div className={Class.root}>
<CameraIcon />
<CameraIcon color="primary" />
<CameraIcon color="secondary" />
<CameraIcon color="action" />
<CameraIcon color="disabled" />

export default HomeIcon

Here’s the result:

MUI Icons in React | refine (4)

The Icon component(Font icons)

The Icon component displays any icon font that supports ligatures. To use an icon, just enclose its name in the Icon component's font ligature.

Here’s a simple illustration of how to import font icons into your React app with the Icon component:

import * as React from 'react';
import Box from '@mui/material/Box';
import { green } from '@mui/material/colors';
import Icon from '@mui/material/Icon';

export default function Icons() {
return (
'& > :not(style)': {
m: 2,
<Icon color="primary">camera</Icon>
<Icon sx={{ color: green[500] }}>camera</Icon>
<Icon fontSize="small">camera</Icon>
<Icon sx={{ fontSize: 30 }}>camera</Icon>

Here’s the result

(Video) How to use Material UI Icons in React App in Hindi in 2020 #42

MUI Icons in React | refine (5)

Notice how we could customise the `font size of some of the icons.

You can also use FontAwesome icons like this:

<FontAwesomeIcon icon="fa-solid fa-aperture" />

Building a Task Tracker with React and Material UI

Material UI icons are a very dynamic element of web design. You can use them to represent commands, actions and directories in a React application. We can showcase their uses and functions in a simple application like a task tracker.

The task tracker will have three components:

  • The Form component
  • The Task component
  • The TaskList component

The Form Component

This component includes an input element where users can type their tasks, as well as an add button represented by Material UI's AddCircleIcon. It also has a Select element where users can customise the task tracker by displaying tasks that have been completed or those that have yet to be completed.

Here’s the code for the Form component

import React, { useState } from "react";
import AddCircleIcon from "@mui/icons-material/AddCircle";

const Form = () => {
const [inputText, setInputText] = useState("");
const [todos, setTodos] = useState([]);
const [status, setStatus] = useState("All");
const [filteredTodos, setFilteredTodos] = useState([]);

const inputTextHandler = (e) => {

const submitTodoHandler = (e) => {

text: inputText,
completed: false,
id: Math.floor(Math.random() * 10000),


const statusHandler = (e) => {

return (
<form className="form-div">
placeholder="Enter New Task Here"
<select onChange={statusHandler}>

export default Form;

Here’s the Form component:

MUI Icons in React | refine (6)

MUI Icons in React | refine (7)

The Task Component

This component displays the user interface and functionalities within the individual tasks that the user specifies. You can delete tasks from the Material UI by clicking the DeleteIcon. By clicking the CheckCircleIcon from Material UI, you can mark a "todo" as "completed."

Here’s the code for the Task component:

import React, { useState } from "react";
import CheckCircleIcon from "@mui/icons-material/CheckCircle";
import DeleteIcon from "@mui/icons-material/Delete";

const Task = () => {
const [todos, setTodos] = useState([]);
const [filteredTodos, setFilteredTodos] = useState([]);

const deleteHandler = () => {
setTodos(todos.filter((el) => !==;

const completeHandler = () => {
setTodos( => {
if ( === {
return {
completed: !item.completed,
return item;

return (
<section className="task-section">
<div className="class-list">
<p className={`${todo.completed ? "pargh2" : "pargh"}`}>
<button onClick={completeHandler} className="btn-2">
<CheckCircleIcon className="icon2" />
<button onClick={deleteHandler} className="btn-1">
<DeleteIcon className="icon1" />

export default Task;

Here’s the Task component

(Video) React Material UI 5 6-Icon Buttons

MUI Icons in React | refine (8)

The TaskList Component

This component maps the various tasks created by the user and displays them as an unordered list in the DOM.

Here’s the code:

import React from "react";
import Task from "./Task";

const Tasklist = () => {
const [todos, setTodos] = useState([]);
const [filteredTodos, setFilteredTodos] = useState([]);

return (
{ => (

export default Tasklist;

Here’s the final result:

MUI Icons in React | refine (9)

Testing MUI Icons

Material UI provides a wide range of regression tests. MUI components are tested internally. @testing-library/react is a library with a first-class API for this approach. MUI icons exported from @mui/icons-material have a data-testid attribute for testing purposes.

For instance:

import CameraIcon from '@mui/icons-material/Camera';

Once mounted, it has the following property:

<svg data-testid="CameraIcon"></svg>


This article reviewed React Material UI and explored its icons, installation, and application processes. We also highlighted a possible use case in a task-tracking application.You can access the source code on Github Repo.

You can also see the deployed application here.



(Video) Icons and Tooltips in Material UI - React Tutorial 92


1. MUI V5: Icons, Svg Icons & Icon Buttons
(Anthony Sistilli)
2. The best way to use icons in React (with React Icons)
(Eric Murphy)
3. Material UI Tutorial #4 - Icons
(The Net Ninja)
4. The Essential MUI Icon Tutorial (Exact Steps!)
(The Clever Dev)
5. React Material UI Tutorial - 4 - Button
6. Icons In React Material UI
(Techinfo YT)
Top Articles
Latest Posts
Article information

Author: Duane Harber

Last Updated: 03/15/2023

Views: 6485

Rating: 4 / 5 (71 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Duane Harber

Birthday: 1999-10-17

Address: Apt. 404 9899 Magnolia Roads, Port Royceville, ID 78186

Phone: +186911129794335

Job: Human Hospitality Planner

Hobby: Listening to music, Orienteering, Knapping, Dance, Mountain biking, Fishing, Pottery

Introduction: My name is Duane Harber, I am a modern, clever, handsome, fair, agreeable, inexpensive, beautiful person who loves writing and wants to share my knowledge and understanding with you.