# Change Image Source

**URL:** <https://community.weweb.io/t/change-image-source/3727>\
**Category:** Ask us anything\
**Created:** [July 31, 2023, 6:49pm UTC](https://community.weweb.io/t/change-image-source/3727 "2023-07-31T18:49:09Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mark](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/mark/32/4163_2.png) [@mark](https://community.weweb.io/u/mark)\
**Post date:** [July 31, 2023, 6:49pm UTC](https://community.weweb.io/t/change-image-source/3727/1 "2023-07-31T18:49:09Z")

</div>

Hi, I have an icon that has 2 versions. Full color and grey. I’m using the Tabs element and I want the grey version to show when that tab is not active. I tried using a custom state but it wont work because when I change the image for 1 the Active state it changes for all of the states.

What’s the best way to do this? I could use 2 different images and show/hide them based on conditions, but I wanted to see if there’s a better way to do it.

---

<div class="post-metadata">

**Author:** ![aurelie](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/aurelie/32/13249_2.png) [@aurelie](https://community.weweb.io/u/aurelie)\
**Post date:** [August 1, 2023, 8:19am UTC](https://community.weweb.io/t/change-image-source/3727/2 "2023-08-01T08:19:46Z")

</div>

The usual way is to use svg icon or font icon, and change the color property using state.

If you really need to change the image url, you cna always bind it to a formula and compare each tab to the actual selected index

---

<div class="post-metadata">

**Author:** ![Antiokh](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/antiokh/32/2794_2.png) [@Antiokh](https://community.weweb.io/u/Antiokh)\
**Post date:** [September 1, 2023, 10:14pm UTC](https://community.weweb.io/t/change-image-source/3727/3 "2023-09-01T22:14:42Z")

</div>

Excuse me, but changing a background image is a usual way in different cases. I’ve tried formulas for bgimage and for source image, nothing works. Works if I use a variable and keep the image url inside, but it means that I need 2 workflows for pretty standard behavior accepted in W3C.

Now here’s a workaround: you can place two images and change their visibility based on parent’s hover state. You can change it via opacity or display option. But we definitely need this option to use images and create a custom design.

---

<div class="post-metadata">

**Author:** ![lissianski](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/lissianski/32/3084_2.png) [@lissianski](https://community.weweb.io/u/lissianski)\
**Post date:** [September 1, 2023, 10:25pm UTC](https://community.weweb.io/t/change-image-source/3727/4 "2023-09-01T22:25:19Z")

</div>

I agree. I am in a similar situation. I have an image (actually an icon) which I want to change on hover. I create a hover state for it, but when I change the image for a hover state, this image is also set for the default state. I used the workaround with a parent div containing the two images and a hover states that is inherited by the two child images. Then I apply block and none display to them. It is a workaround though.

---

<div class="post-metadata">

**Author:** ![aurelie](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/aurelie/32/13249_2.png) [@aurelie](https://community.weweb.io/u/aurelie)\
**Post date:** [September 4, 2023, 9:46am UTC](https://community.weweb.io/t/change-image-source/3727/5 "2023-09-04T09:46:42Z")

</div>

Hey,  
can you explain me more what does not work for binding formula on the source url? Can you give me an example?

@lissianski its because the url (or icon) is not statefull. We were thinking that this was not a common case, as you have to load the image on hover (which take time). Can you explain me more your usecase?

I opened a product ticket for this usecase, but we need to understand more your exact usecase (icon and image if i follow) to be sure to specify it correctly.

---

<div class="post-metadata">

**Author:** ![Antiokh](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/antiokh/32/2794_2.png) [@Antiokh](https://community.weweb.io/u/Antiokh)\
**Post date:** [October 10, 2023, 6:06pm UTC](https://community.weweb.io/t/change-image-source/3727/6 "2023-10-10T18:06:06Z")

</div>

No problem. You create a button, set a bgimage, switch to “hover” and change an image. When you return to the initial state, you see the image from “hover” state.
