Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@svgr/plugin-jsx

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@svgr/plugin-jsx

Transform SVG into JSX

  • 4.3.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7.7M
decreased by-7.77%
Maintainers
1
Weekly downloads
 
Created

What is @svgr/plugin-jsx?

@svgr/plugin-jsx is a plugin for SVGR (SVG to React) that transforms SVG files into JSX code. This allows developers to use SVGs as React components, making it easier to integrate and manipulate SVG graphics within React applications.

What are @svgr/plugin-jsx's main functionalities?

Basic SVG to JSX Transformation

Transforms a basic SVG string into JSX code that can be used as a React component.

const svgCode = '<svg><circle cx="50" cy="50" r="40" /></svg>';
const jsxCode = transform(svgCode, { plugins: ['@svgr/plugin-jsx'] });
console.log(jsxCode);

Customizing JSX Output

Allows customization of the JSX output using Babel presets and other configurations.

const svgCode = '<svg><circle cx="50" cy="50" r="40" /></svg>';
const jsxCode = transform(svgCode, { plugins: ['@svgr/plugin-jsx'], jsx: { babelConfig: { presets: ['@babel/preset-react'] } } });
console.log(jsxCode);

Adding Props to SVG Components

Automatically adds props to the SVG components, making them more flexible and reusable.

const svgCode = '<svg><circle cx="50" cy="50" r="40" /></svg>';
const jsxCode = transform(svgCode, { plugins: ['@svgr/plugin-jsx'], jsx: { expandProps: 'start' } });
console.log(jsxCode);

Other packages similar to @svgr/plugin-jsx

Keywords

FAQs

Package last updated on 24 Sep 2019

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc