active ( boolean ; optional): Whether button is in active state. Default: False.
I was wondering to use this property instead of n_clicks to simplify the callback, if the active is False then no_update, if it is True then execute the callback, but I notice that when I clicked the button the active property do not change althought the button change its appearance (it looks active ),
Not a bug, or at least itβs intentional. The active prop is to be used as an override when you want the Button to be styled as active rather than allow it to set its style based on hover or click events. It is therefore not meant to represent whether the button is currently styled as active, rather whether it is currently being overridden as active.
Using active to trigger a callback is interesting, but I think better to have consistency with html.Button and dcc.Button by using n_clicks rather than have multiple ways to accomplish the same thing.
Thanks @tcbegley, I understand the idea, you can use the property to change the button style but not the other way
The problem with n_clicks is that you donβt have a direct way to know if the button was the trigger of the calback when the button was used before, it needs to use aditional options like callback_context.
Put this in your callback and should show the list of components that triggered it. I use it to determine which button was clicked in mine and then do something specific based on that.