Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Custom hook to add a viewbox attribute to your SVG in case it's missing.

License

the-road-to-learn-react/use-with-viewbox

Repository files navigation

useWithViewbox React Hook

Build Status Slack Greenkeeper badge NPM

Custom hook to add a viewbox attribute to your SVG in case it's missing. It calculates the viewbox based on the rendered svg element with its height and width. Read more about it here.

Installation

npm install use-with-viewbox

Usage

import useWithViewbox from 'use-with-viewbox';
const MySvg = (props) => {
 const ref = React.createRef();
 useViewbox(ref);
 return (
 <svg ref={ref} {...props}>
 // SVG Content ...
 </svg>
 );
};
export default MySvg;

Contribute

  • git clone git@github.com:the-road-to-learn-react/use-with-viewbox.git
  • cd use-with-viewbox
  • npm install

More

About

Custom hook to add a viewbox attribute to your SVG in case it's missing.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published

AltStyle によって変換されたページ (->オリジナル) /