for example, I whould like to add a row or change some other layout of the frame when i click a button. how can i do this operation.
You can change the visibility of a row by returning gr.update(visible=True)
or gr.update(visible=False)
and assign the output to be a Row
Hi @abidlabs. Do you know if I can update the css (of the block element)? Iβm trying to update the color of a button.
Hi @miguelwon yes you can change the color of buttons in your Gradio app using either themes or custom css.
-
If youβd like to change the color of buttons throughout your entire app, you should create a custom theme, itβs pretty easy using gradioβs built-in theme editor: Theming Guide.
-
If youβd like to change the color of a specific button, you can assign it an
elem_id
and target it using custom css, as described here: Custom CSS And JS
Hi and thanks for the reply.
Sorry, I was not very clear. I want to know if I can update it dynamically.
Hi @miguelwon you can update properties of a gr.Button()
component by returning gr.Button.update(...)
from your function, as described here: Gradio update Docs
So there are two possibilities here:
- You could update the
variant
property, which (in the default theme) changes the color (from gold ifvariant
isprimary
, gray ifsecondary
, red ifstop
) - You could create two different buttons, style them as you want, and then toggle the visibility of the buttons from your function which would make it appear as if the color has changed.