Set the color of the button based on some criteria

So, like we can change button label and a badge content with formula, it will be cool to have that ability for the color as well. Right now all buttons in the same column should be the same color, if they are not disabled, of course.

9 Likes

+1

FYI if you need any sort of distinction, what you can do at the moment is keep all the buttons white and change text color using _Color() formula on the label

11 Likes

Great idea :pause_button::stop_button::record_button::arrow_forward:

+1

Yeah, totally needed, as color distinction is often more relevant than customizable text.

@Paul_Danyliuk » Awesome workaround, thanks! May I ask where did you find this function? It’s totally not in the documentation, which makes me somewhat sad, since that’s exactly the place I’d expect to find solutions to trickier problems.

This is one of the hidden formulas, which aren’t guaranteed to stay like that, and are probably only there to be a staple for some internal Coda workings.

Re how I found these: Set a color in conditional format by formula - #8 by Paul_Danyliuk

And here is a thread with more efforts to make use of these:

2 Likes

Thanks :slight_smile:

Actually… :wink:

And it was in plain sight, in that topic about hidden formulas. Props to @Filmos for finding the list of valid color values and for tinkering with the Button() function.

Important: other color values will crash the doc. Partially typed in values (e.g. when you start typing "Purp" within quotes) will also crash the doc. You won’t be able to recover it unless you open another section by link and delete the section where the incorrectly setup button is displayed (i.e. avoid seeing the button and triggering the crash again)

@Denis_Peshekhonov @Jean_Pierre_Traets @Tomas_Bachtik

12 Likes

Sounds Great (apart from that scary crashing part :smiley: ), and I have to admit since the functions don’t have their arguments mentioned, I never expected the button to offer this functionality - so thanks for digging in! :heart:

Hi there,
It seems that using incorrect icon names crash it as well.
Do you know a list of valid icon names?

1 Like

Alert types:

  • None
  • All
  • Errors

Icons (in no particular order):

  • lightning
  • circle
  • star
  • cocktail
  • battery
  • person
  • coffee
  • currency
  • smiley
  • chili
  • heart
  • thumbsup
  • bell
  • diamond
  • bug
  • fire
  • lightbulb
  • checkmark
  • sun
  • cloud

Please note though that these Button-wrapped buttons take quite a lot of space in the doc, so use them sparingly in tables that you expect to grow big.

7 Likes

Thanks a lot @Paul_Danyliuk
I’ll be using it in a <600 rows table.

Cheers

All the text on the buttons is _bold() - have you figured out how to get plaintext?

It’s not bold really, it’s medium (i.e. it can be bolder).
No, I haven’t.

And yeah, lately I’m trying to avoid using the Button() formula altogether, knowing how it was broken for a few days recently and how it could potentially damage the doc. That is until we have a Coda-approved solution to render these (i.e. with an approved formula or some custom extension, if those ever ship)

@Paul_Danyliuk hey what do you mean by ‘damage the doc’? Something like this?

Oh, just checked and they fixed the fatal crash.
There used to be an issue here. When you started typing out the color (i.e. it inserted you "" and you typed in the first letter, e.g. "Y") the doc would immediately crash and keep crashing even after reloading the page.

Seems like Button() is pretty safe now. No arguments would cause such a crash. Incorrect values would just be silently ignored.


Meaning you can finally remove the filters and learn who has a crush on whom.

3 Likes

The color of the text in a button (including it’s background-color) can be set using SVG

Here is an example

2 Likes

What does actionBuilderOptions do?

No idea :slight_smile:

I haven’t explored that one and it’s not apparent. I’d assume it could be some internal settings as to how actions should be run (sequentially or in parallel). Furthermore I think at the moment it does nothing, i.e. it’s just a reserved parameter. Otherwise I’d see it set in existing buttons when exploring their internal representation, and so far I haven’t.