{"id":21547264,"url":"https://github.com/the-road-to-learn-react/use-with-viewbox","last_synced_at":"2026-05-19T11:10:28.411Z","repository":{"id":57388517,"uuid":"193857958","full_name":"the-road-to-learn-react/use-with-viewbox","owner":"the-road-to-learn-react","description":"Custom hook to add a viewbox attribute to your SVG in case it's missing.","archived":false,"fork":false,"pushed_at":"2020-06-12T08:24:44.000Z","size":161,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-15T20:11:22.935Z","etag":null,"topics":["react","react-svg","reactjs","svg-viewbox"],"latest_commit_sha":null,"homepage":"https://www.robinwieruch.de","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/the-road-to-learn-react.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"rwieruch","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2019-06-26T08:02:03.000Z","updated_at":"2020-06-12T08:24:47.000Z","dependencies_parsed_at":"2022-09-19T02:10:57.887Z","dependency_job_id":null,"html_url":"https://github.com/the-road-to-learn-react/use-with-viewbox","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/the-road-to-learn-react%2Fuse-with-viewbox","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/the-road-to-learn-react%2Fuse-with-viewbox/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/the-road-to-learn-react%2Fuse-with-viewbox/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/the-road-to-learn-react%2Fuse-with-viewbox/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/the-road-to-learn-react","download_url":"https://codeload.github.com/the-road-to-learn-react/use-with-viewbox/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244141582,"owners_count":20404835,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["react","react-svg","reactjs","svg-viewbox"],"created_at":"2024-11-24T06:14:38.425Z","updated_at":"2026-05-19T11:10:23.377Z","avatar_url":"https://github.com/the-road-to-learn-react.png","language":"JavaScript","funding_links":["https://github.com/sponsors/rwieruch"],"categories":[],"sub_categories":[],"readme":"# useWithViewbox React Hook\n\n[![Build Status](https://travis-ci.org/the-road-to-learn-react/use-with-viewbox.svg?branch=master)](https://travis-ci.org/the-road-to-learn-react/use-with-viewbox) [![Slack](https://slack-the-road-to-learn-react.wieruch.com/badge.svg)](https://slack-the-road-to-learn-react.wieruch.com/) [![Greenkeeper badge](https://badges.greenkeeper.io/the-road-to-learn-react/use-with-viewbox.svg)](https://greenkeeper.io/) ![NPM](https://img.shields.io/npm/l/use-with-viewbox.svg)\n\nCustom 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.](https://www.robinwieruch.de/react-svg-icon-components/)\n\n## Installation\n\n`npm install use-with-viewbox`\n\n## Usage\n\n```\nimport useWithViewbox from 'use-with-viewbox';\n\nconst MySvg = (props) =\u003e {\n  const ref = React.createRef();\n\n  useViewbox(ref);\n\n  return (\n    \u003csvg ref={ref} {...props}\u003e\n      // SVG Content ...\n    \u003c/svg\u003e\n  );\n};\n\nexport default MySvg;\n```\n\n## Contribute\n\n- `git clone git@github.com:the-road-to-learn-react/use-with-viewbox.git`\n- `cd use-with-viewbox`\n- `npm install`\n\n### More\n\n- [Publishing a Node Package to NPM](https://www.robinwieruch.de/publish-npm-package-node/)\n- [Node.js Testing Setup](https://www.robinwieruch.de/node-js-testing-mocha-chai/)\n- [React Testing Setup](https://www.robinwieruch.de/react-testing-tutorial/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthe-road-to-learn-react%2Fuse-with-viewbox","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthe-road-to-learn-react%2Fuse-with-viewbox","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthe-road-to-learn-react%2Fuse-with-viewbox/lists"}