
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
This package lets you dynamic import your svg images as a Next.Js component as a parameter, with no problem at all.
next-svg
is a lightweight module that provides React component that is especially designed to simplify the integration of SVG images into Next.js applications. With next-svg
, you can momentarily and in satisfactory way import and render SVG files, customize and manage their appearance properties like color, width, height.
npm install next-svg
.Svg
from this module as the default import into a JSX/TSX file.name
(the filename without extension)./public/svg
directory. Ensure all your SVG files are placed there. If you wish to organize them into subdirectories, utilize the subdirectory
prop.SVGs are often poorly implemented, the written code lacks cleanliness and sufficient abstraction, and it struggles with dark mode compatibility and color customization. Picture having a multitude of icons or other SVG images and wanting to manage them in a rational manner to avoid getting lost in the process - not possible.
To install next-svg
in your Next.js project, simply run:
npm i next-svg
or
yarn add next-svg
Import next-svg
module in your React component file:
import Svg from 'next-svg';
Then, use the Svg
component in your JSX/TSX file to render SVG images:
<Svg name="icon" />
The Svg
component accepts the following props:
name
(required): The filename of the SVG image to render (no .svg
extension needed).subdirectory
(optional): The subdirectory within the /public/svg/
directory where the SVG file is located.className
(optional): Additional CSS class names to apply to the container div.color
(optional): The fill color of the SVG image (accepts CSS values).width
(optional): The width of the SVG image (accepts CSS values).height
(optional): The height of the SVG image (accepts CSS values).alt
(required) Text to show when loading of an svg failed.import React from 'react';
import Svg from 'next-svg';
const MySvgComponent = () => {
return (
<Svg name="logo" subdirectory="icons" className="logo" color="blue" width={100} height={100} />
);
};
export default MySvgComponent;
In this example, the file path is public/svg/icons/logo.svg
. The SVG is rendered with a blue fill color and a width and height of 100 pixels. Div in which SVG file is placed gains all styles from className logo
.
Contributions to the development of the custom SVG folder configuration feature are highly encouraged! If you wish to contribute, please adhere to the following guidelines:
Fork the repository and create a new branch for your changes.
Implement your changes following the project's coding standards and conventions.
Submit a pull request with a descriptive summary of the proposed changes and their rationale.
Engage in constructive discussions and address any feedback or suggestions from the maintainers.
Your feedback and suggestions regarding the custom SVG folder configuration feature are invaluable! If you have any questions or ideas, please don't hesitate to reach out. Your input will help shape the future development of this project.
This project is licensed under the MIT License - see the LICENSE.md file for details.
FAQs
This package lets you dynamic import your svg images as a Next.Js component as a parameter, with no problem at all.
The npm package next-svg receives a total of 19 weekly downloads. As such, next-svg popularity was classified as not popular.
We found that next-svg demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.