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

@svgr/webpack

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@svgr/webpack

SVGR webpack loader.

  • 6.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4.4M
decreased by-28.37%
Maintainers
1
Weekly downloads
 
Created

What is @svgr/webpack?

The @svgr/webpack package is a webpack loader that allows you to import SVG files as React components. This enables you to manipulate SVGs in your React applications with ease, such as changing colors or sizes, and integrating them as if they were regular React components.

What are @svgr/webpack's main functionalities?

Import SVGs as React Components

This feature allows you to import an SVG file directly into a React component file and use it as a React component. The SVG file is transformed into a React component, which can then be rendered in the JSX.

import React from 'react';
import { ReactComponent as Logo } from './logo.svg';

const App = () => (
  <div>
    <h1>Welcome to React</h1>
    <Logo />
  </div>
);

export default App;

Customize SVGs with Props

This feature allows you to pass props to the imported SVG component to customize its appearance. You can change the fill color, size, and other properties by passing props as you would to any other React component.

import React from 'react';
import { ReactComponent as Star } from './star.svg';

const App = () => (
  <div>
    <Star fill="#FFD700" width={100} height={100} />
  </div>
);

export default App;

Use with CSS Modules

This feature integrates with CSS Modules, allowing you to apply scoped CSS to the SVG component. You can style the SVG using a CSS module and pass the generated class name as a prop to the SVG component.

import React from 'react';
import styles from './App.module.css';
import { ReactComponent as Logo } from './logo.svg';

const App = () => (
  <div className={styles.app}>
    <Logo className={styles.logo} />
  </div>
);

export default App;

Other packages similar to @svgr/webpack

Keywords

FAQs

Package last updated on 10 Jan 2022

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