-
Notifications
You must be signed in to change notification settings - Fork 839
feat(Icon): allow passing a component instead of a name #4766
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
base: v4
Are you sure you want to change the base?
Conversation
commit: |
c6213e3
to
7030f2d
Compare
Right now I am unable to access Vercel so I do not know what the deployment error is. |
Maybe it's also worth adding the ability to pass icons in template slots, but that will be a bigger change. Maybe that's a better way then passing a component in props though: <script setup lang="ts">
import IconLightbulb from '~icons/lucide/lightbulb'
</script>
<template>
<UButton :trailing-icon="IconLigthbulb">Button</UButton>
<!-- VS -->
<UButton>
<template #trailing-icon><IconLightbulb /></template>
Button
</UButton>
</template> |
The fact that you cannot pass an icon component into appConfig bugs me, but I am not sure if I can do anything about it without it looking like a horrible hack. Ideas I came up with, all have their downsides:
EDIT: I forgot that Also I feel like |
7f055cf
to
3e38fac
Compare
So:
|
I don't think it is necessary to rename |
This reverts commit c1230f9.
π Linked issue
Resolves #4728
β Type of change
π Description
Previously, all icon props in components only accepted string values representing icon names (e.g.
"i-lucide-rocket"
). Icons defined this way would be loaded from a CDN, which results in absence of icons altogether when CDN is unavailable for one reason or another.Current solution for this is to statically bundle all of the used icons into the application, which is unacceptable when bundle size is of importance and when knowing all of the used icons in the project is impossible.
This PR allows user to pass a Vue component instead of an icon name in every component that has an icon prop.
UIcon
by itself will just render the passed component unchanged, so scaling has to be done either by applying styles toUIcon
or to the Vue component.I was unable to allow setting component icons inside the global config, because it is passed through
JSON.stringify
to expose config as a virtual module, and components obviously do not survive that process.I can backport this to v3 if you want.
π Checklist