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 add icons from a variable #78

Closed
rashidpathiyil opened this issue Feb 27, 2021 · 3 comments
Closed

How to add icons from a variable #78

rashidpathiyil opened this issue Feb 27, 2021 · 3 comments

Comments

@rashidpathiyil
Copy link
Contributor

rashidpathiyil commented Feb 27, 2021

How to add when icon name is inside a variable?

const icon="carbon-user" 

<carbon-user class="text-5xl" />

This is not working on Vitesse
<span class="iconify" data-icon="carbon:center-circle" data-inline="false"></span>

@SamuelAlev
Copy link

SamuelAlev commented Feb 27, 2021

You should be able to use <component :is="icon" />. (docs)

If it is not working, I would suggest you to use his old Icon component

@antfu
Copy link
Member

antfu commented Feb 27, 2021

@rashidpathiyil The syntax you provide requires Iconify runtime, where you can use it with purge-icons installed. https://github.com/antfu/purge-icons/tree/main/packages/vite-plugin-purge-icons Or just simply import @iconify/iconify if you don't need to bundle them.

Otherwise, @SamuelAlev already offered the solution.

@antfu antfu closed this as completed Feb 27, 2021
@rafalolszewski94
Copy link

now how to do you use icons from variable using unocss icons?

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

4 participants