Importing SVGs In React: The Clean Way

Royer Adames
Aug 5, 2021
import { ReactComponent as [your_image_name]} from “your image path”

Then you can use the SVG like any component.

React component that renders an inline SVG

Pros and cons of inline image and object SVG import

Remember to remove all inline styles that the SVG may have so your className can change the styles.

Removing SVG styles

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Royer Adames
Royer Adames

No responses yet

Write a response