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

react-svg

Package Overview
Dependencies
Maintainers
0
Versions
366
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-svg

A React component that injects SVG into the DOM.

  • 16.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
167K
decreased by-3.89%
Maintainers
0
Weekly downloads
 
Created

What is react-svg?

The react-svg npm package is a React component that allows you to easily include and manipulate SVG files in your React applications. It provides a simple way to load SVG files and apply various transformations and customizations to them.

What are react-svg's main functionalities?

Basic SVG Loading

This feature allows you to load an SVG file into your React component. The 'src' prop specifies the path to the SVG file.

<ReactSVG src="/path/to/your.svg" />

Customizing SVG with Props

This feature allows you to customize the SVG before it is injected into the DOM. The 'beforeInjection' prop is a function that receives the SVG element and allows you to manipulate it.

<ReactSVG src="/path/to/your.svg" beforeInjection={(svg) => { svg.classList.add('svg-class'); svg.setAttribute('style', 'width: 200px'); }} />

Using SVG as a Component

This feature allows you to use the SVG as a React component, making it easy to include and manage within your React application.

import { ReactSVG } from 'react-svg';

const MyComponent = () => (
  <ReactSVG src="/path/to/your.svg" />
);

Handling SVG Load Events

This feature allows you to handle events when the SVG is loaded. The 'onLoad' prop is a function that is called when the SVG has been successfully loaded.

<ReactSVG src="/path/to/your.svg" onLoad={() => console.log('SVG loaded!')} />

Other packages similar to react-svg

Keywords

FAQs

Package last updated on 19 Nov 2024

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