New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More

babel-plugin-react-svg

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-react-svg

Babel plugin to transform svg to react component


Version published
Weekly downloads
139K
decreased by-0.15%
Maintainers
1
Weekly downloads
 
Created

What is babel-plugin-react-svg?

The babel-plugin-react-svg package is a Babel plugin that allows you to import SVG files as React components. This can be particularly useful for incorporating SVGs directly into your React components without having to manually convert them.

What are babel-plugin-react-svg's main functionalities?

Importing SVG as React Component

This feature allows you to import an SVG file and use it as a React component. The SVG file is transformed into a React component, which can then be used like any other React component.

import MyIcon from './icon.svg';

const App = () => (
  <div>
    <MyIcon />
  </div>
);

Customizing SVG with Props

You can pass props to the imported SVG component to customize its attributes such as width, height, and fill color. This makes it easy to reuse the same SVG with different styles.

import MyIcon from './icon.svg';

const App = () => (
  <div>
    <MyIcon width="50" height="50" fill="red" />
  </div>
);

Other packages similar to babel-plugin-react-svg

FAQs

Package last updated on 17 Mar 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts