News Letter About Us


Integrate SVGs in React as a Component

How to integrate SVG image (svg file) in your react app as a component      October 9, 2020

Shubham Verma

Shubham Verma

Integrate SVGs in React as a Component


n this article, we'll see what is the SVG and how we can integrate SVGs in our React app. Sometime we have our own custom image/icon as SVG (.svg file), and we need to integrate this file in our app (need to show as an image). So in this article, we will learn, how we can integrate this svg file in our component.

What is SVG?

SVG is basically lines of codes that is written like XML, ( the format of thus code is XML ). SVG is a vector graphics image. SVG stands for Scalable Vector Graphics. It was developed in the late 1990s and that time it was not famous, But right now the SVGs are very popular. So many big organizations are using SVGs. SVG uses shapes, numbers, and coordinates instead of pixel grids like other image formats do. This makes it possible to zoom in and out of SVG images without losing any quality and gives SVG the ability to scale infinitely The file sizes of SVG images are usually small compared to other file.

Let's have an SVG:

Let's see an SVG file, the below file is an SVG file.


If you integrate this file then it will look like this:

Integrate SVGs in React as a Component


Integrate this SVG in React app:

Using the above SVG in your react componet is very simple, You need to import the above file in your component (The above SVG codes would be as it is. No need to change or no need to make a react component.). And after you need to use that as a component like described as:

After importing, you can use as you use other React component, as:

Thats it.

Thank you

for taking the time to read this article. If you’re interested in Node.js or JavaScript this link will help you a lot.

If you found this article is helpful, then please share this article's link to your friends to whom this is required, you can share this to your technical social media groups also. You can follow us on our social media page for more updates and lates article updates.

Copyright © 2020 IDKBlogs | All Right Reserved

About Us

Powered by : IDKBlogs

Last Update : 12 Jan 2021