<svg
xmlns='https://www.w3c.org/2000/svg'
version='1.1'
width='36'
height='36'
viewbox='0 0 36 36'>
<path fill='#fff'/>
</svg>
Next에서는 약간의 설정이 필요합니다.
npm i --dev @svg/webpack
const nextConfig = {
reactStrictMode: true,
webpack( config ) {
config.module.rules.push( {
test: /\.svg$/,
use: ["@svgr/webpack"]
} );
return config;
},
}
module.exports = nextConfig
import Icon from './public/icon.svg'
<img src={Icon}/>
import Icon from './public/icon.svg'
<div>
<Icon />
</div>
svg에서 수정하고 싶은곳을 current로 바꿔줍니다.
<svg
width='current'
height='current'>
<path fill='current'>
</svg>
width, height, fill을 prop으로 내려줍니다.
import Icon from './public/icon.svg';
<Icon width='24' height='24' fill='red'/>;