vite-plugin-svgr icon indicating copy to clipboard operation
vite-plugin-svgr copied to clipboard

How to concatenate to existing `class` on `<svg>`, instead of overwriting them?

Open xsjcTony opened this issue 1 year ago • 0 comments

SVG:

<svg class="animate-spin" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" width="1em" height="1em">
  <circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4" />
  <path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" />
</svg>

React Component:

import { ReactComponent as SpinnerIcon } from '@assets/icons/spinner.svg';

export default function App() {
  return <SpinnerIcon className="absolute" />
}

Will result in <svg class="absolute" ...> instead of <svg class="animate-spin absolute" ...>

xsjcTony avatar Aug 24 '23 10:08 xsjcTony