Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

importing svg into react

import React from 'react';
import { ReactComponent as BrandIcon } from "./assets/brand-icon.svg";

export default function(){
  return( 
      <div>
          <BrandIcon />
      </div>
   );
}
Comment

import svg react

import React from 'react';
import LogoName from '../assets/logo.svg'

const Header = () => {
    return ( 
        <div>
           	<img src={LogoName} alt="logo"/>
        </div>
     );
}
Comment

how to import svg in react

//customIcon.js

import React from "react";
import {ReactComponent as ImportedSVG} from "path/to/myIcon.svg";
import { SvgIcon } from '@material-ui/core';

function CustomIcon() {
 return(
  <SvgIcon component={ImportedSVG} viewBox="0 0 384 512"/>

)
}

export default CustomIcon;
Comment

import svg as react component

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

const MyComponent = () => {
    return(
        <YourSvg/>
    );
}

export default MyComponent ;
Comment

svg component react js

import { ReactComponent as IconMenu } from './icons/menu.svg'

<IconMenu />
Comment

Svg as a component react

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

const App = () => {
  return (
    <div className="App">
      <ReactLogo />
    </div>
  );
}
export default App;
Comment

how to add svg file in react

import YourSvg from "/path/to/image.svg";

const App = () => {
  return (
    <div className="App">
      <img src={YourSvg} alt="Your SVG" />
    </div>
  );
};
export default App;
Comment

add svg in react

<span>
                  <object style={{ float: 'left', height: '15px', position: 'relative', top: '4px' }} data={`${ROOT_URL}/assets/images/svg-icons/history-icon.svg`} type='image/svg+xml'></object>
                </span>
Comment

react svg

//Use this WEB APP to convert any svg to a valide reactJs or React native Component
Playground - SVGR
https://react-svgr.com/playground/
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to change package name in ios react native 
Javascript :: how to limit characters in number input js 
Javascript :: deep merge nested objects javascript 
Javascript :: jquery dropdown select 
Javascript :: payloadtoolargeerror node js 
Javascript :: toggle button javascript 
Javascript :: set attribute in javascript 
Javascript :: prisma seed 
Javascript :: dynamic route vue 
Javascript :: jqueyr element is hide 
Javascript :: convert mongodb timestamp to date javascript 
Javascript :: react native apk bundle 
Javascript :: javascript largest number in array 
Javascript :: jest expect not contain 
Javascript :: ifsc code yup validation 
Javascript :: export all functions 
Javascript :: change title react 
Javascript :: set in javascript 
Javascript :: javascript storage get set item 
Javascript :: add required attribute javascript 
Javascript :: express js url with id 
Javascript :: find input by value attribute javascript 
Javascript :: if cart empty shopify 
Javascript :: suspense react 
Javascript :: how to remove class in all siblings javascript 
Javascript :: reset div jquery 
Javascript :: hmac_sha256 node 
Javascript :: document.append 
Javascript :: difference between find and filter javascript 
Javascript :: copying object javascript 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =