Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
xsjcTony opened this issue Aug 24, 2023 · 0 comments

Comments

@xsjcTony
Copy link

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" ...>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant