-
-
Notifications
You must be signed in to change notification settings - Fork 17
vite plugin and react dynamic change icon not work #17
Comments
What's your |
@antfu It just hoc component, I clear the code,
but also can not dynamic change according to state |
Iconify has a runtime that replaces the DOM with <a onClick={toggleTheme}>
{currentTheme?.name === 'dark-default' ? (
<span><span data-icon="mdi:lightbulb-outline" className="iconify" /></span>
) : (
<span><span data-icon="mdi:lightbulb-on-outline" className="iconify" /></span>
)}
</a> Or you can give a try with the official react component for Iconify: https://github.com/iconify/iconify-react |
{currentTheme?.name === 'dark-default' ? (
<span>
<span data-icon="mdi:lightbulb-outline" className="iconify" />
</span>
) : (
<span>
<span data-icon="mdi:lightbulb-on-outline" className="iconify" />
</span>
)} still can't work 😂 |
Hii @antfu I'm facing a similar situation with Vue, <script setup lang="ts">
import { defineProps } from 'vue';
defineProps({
size: String,
icon: String,
});
</script>
<template>
<span v-bind="$attrs">
<i
:style="{ fontSize: size || '20px', verticalAlign: '-0.25em' }"
class="iconify"
:data-icon="icon"
:data-inline="true"
/>
</span>
</template> This is where I want to use it dynamically, <FButton
@click="handleCommentCollapse"
:icon="isExpand ? 'ion:expand-outline' : 'ion:contract-outline'"
size="17px"
sm
:title="`${isExpand ? 'Expand' : 'Collapse'} comments`"
/> Currently I'm using |
I have a similar issue here using Nuxt JS. <template>
<button @click="toggleMenu" >
<span
v-if="isMenuOpen"
class="h-6 w-6 iconify"
fill-rule="evenodd"
clip-rule="evenodd"
data-icon="ion:close"
></span>
<span
v-else
class="h-6 w-6 iconify"
fill-rule="evenodd"
clip-rule="evenodd"
data-icon="ion:menu"
></span>
</button>
</template> |
Hey @antfu, I have an isolated Vitesse repro for this issue. Let me know if you need anything else. Absolutely loving this setup. <div class="w-400px text-center mx-auto my-0">
<p>Click <a class="underline text-indigo-500" @click="show = !show">here</a></p>
<p>Showing? {{ show }}
<i :data-icon="show ? 'mdi:heart' : 'mdi:heart-broken'" class="iconify text-red-500" />
</p>
</div> |
@JessicaSachs it's kinda a limitation of how Iconify runtime implemented #17 (comment) you can try to adapt to this component: |
Ohhh. Now I understand that comment. Honestly, since the iconify runtime causes a FOUC I just switched to using your Vite Icons Plugin. 😅 |
Icon always be static,like follow image
vite config
main.tsx
icon code, always be first icon 'lightbulb-outline'
but antd icon use its own component work fine
and
The text was updated successfully, but these errors were encountered: