Dynamic Progress Bar within the Label's Button 💡

Hi there fellow Makers :grin: !

Creating and using “Progress Bar” within Coda has always been one of my favorite trick… The trick that blew my mind when I stumbled upon it, not long after joining this awesome Community :star2: !

“Progress Bars” can be used in various ways : you could create HSL Sliders, a visual summary of your day or your budgets

One thing I never thought about though, was to use a progress bar within the label of a button to show the progress of the button’s action, while the action runs :bulb: … and of course, I was in amazed by seeing it done in @Paul_Danyliuk wonderful Duplicates Finder & Merger Template :raised_hands: :star_struck:, not only by the astounding template Paul created but by how this “small” visual detail made a huge difference :grin: .

In case, you’ve missed it or don’t know what I’m talking about, just look at the Find duplicates button in the gif below :wink: :point_down:

The thing is that I didn’t really see how to create such “Progress Bar” :thinking: … So yesterday, I finally gave it a try and found a way, which is why I’m here :blush: .

But first, let’s just talk a little bit about…

:bulb: “Progress Bars” in Coda

A progress bar can be created by concatenating X number of Rectangle() you would need…

Concatenate(Rectangle(),Rectangle()) => Progress Bar

Where the Width of each Rectangle() is a fraction (%) of the total Width of the resulting “Progress Bar” :blush: .

Just to illustrate…

In my 1st Rectangle()

Rectangle(120 * Percent_1/100, 15, Color_1)

120 is the whole Width of my Progress Bar from which we only keep 40% …
(15 is for the Height and Color_1 is the color of this rectangle should have)

In my 2nd Rectangle()

Rectangle(120 * Percent_2/100, 15, Color_2)

120 is still the whole Width of my Progress Bar but this time we keep 60% …

Rectangle 1 + Rectangle 2 => 100% => The Progress Bar

Now that we know this… here’s how I was able to get a …

:bulb: Dynamic Progress Bar within the Label of a Button

As I needed an Action I knew would run for “a while” I used a canvas button to create all dates for the first quarter (Q1) of 2022 :blush: . (It just adds 1 row/per dates in the table called [2022 - Q1])

The Action Formula looks like this:

      [2022 - Q1],
      [2022 - Q1].Date,

And I ended up with this formula for the Label of that button:

    [2022 - Q1].Count() = 0,
    "Create Q1 2022",
    [2022 - Q1].Count() >= 1 AND [2022 - Q1].Count() < RowsCount,
          120 * [2022 - Q1].Count()/RowsCount, 10, "#5cff85"
          120 - (120 * [2022 - Q1].Count()/RowsCount), 10, "#a0a0a0"
    [2022 - Q1].Count() = RowsCount,

The 1st condition in the SwitchIf() is the text to display when the button has not been clicked yet : and the 3rd condition is to display “Done!” when the Action is completed and the button added all the needed rows :blush: .

The 2nd SwitchIf() condition is where the “magic” :sparkles: happens but this time, the Width of each Rectangle() is determined by “how complete the Action is” and in this case, the Action is complete when the numbers of rows in the table is equal to the numbers of rows I ask the button to add :blush: .

[2022 - Q1].Count() = RowsCount

And RowsCount being:


So in my 1st Rectangle()

          120 * [2022 - Q1].Count()/RowsCount,10,"#5cff85"

120 is the whole Width of the Progress Bar (i.e.: 100%) from which we only keep the portion equal to [2022 - Q1].Count()/RowsCount

For the 2nd Rectangle():

          120 - (120 * [2022 - Q1].Count()/RowsCount), 10, "#a0a0a0"

As the Progress Bar needs to reflect an “empty” state at the beginning of the Action, then it needs to reflect a “fuller” state as the Action progresses and as 120 is still the whole Width of the Progress Bar, the Width of this rectangle can be determined by 120 - (120 * [2022 - Q1].Count()/RowsCount) :blush:

And that’s it :innocent: !

Sorry for the length :sweat_smile: … But thanks for reading :raised_hands: !

I won’t be able to thank @Paul_Danyliuk enough for the inspiration, so I’m just going to stick with a simple Thank you so so so very much :raised_hands: :grin: :bulb: !!!

I’m pretty sure you’ll probably have things to add and/or correct here and there :wink:


Wow! What a cool trick @Pch. Thanks for sharing such a thoughtful and detailed writeup. I’ll certainly be using this in future docs.


this is so amazing!!! thank you for the detailed writeup


This is pretty slick - nice work!


Really love this little piece of UX delight. Great idea, and beautifully written guide. Definitely going into the bookmarks, thanks gents :slight_smile:

1 Like