How to set a tab icon?

  • Goal: To set an icon on a tab based on a condition. Also if we can set a tag that will work as well because it looks similar.

Trying to match the design like so.

  • Steps:

I tried setting an icon to a tab like this pulseTabs.iconByIndex[0] = icon1 where icon1 is an icon I added to the app.

However I don't see the icon appear, there are no errors that show in the console, and this doesn't appear to add an icon unless it's already in the app.

  • Details:

I'm using the tabs component linked to a container

Hi @Drew_Gallagher!
It's not possible to set state in Retool without an associated set* API on the component, but you can define the icon field declaratively by configuring the Icon field using a template string.

This screenshot assumes that you've set up some sort of variable with boolean state in your code, which you can control via scripts or event handlers (someCondition.setValue(false))

2 Likes