Unable to remove class "bg-primary" from button #1445
-
DescriptionVery possible that I'm missing something obvious, but why is from nicegui import ui
ui.button('Click me!', on_click=lambda: ui.notify(f'You clicked me!')).classes(remove='bg-primary')
ui.run() |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
The default background color of a button is not generated with a class but with a prop. Therefore removing "bg-primary" does not work. ui.button('Click me!', color='white') or ui.button('Click me!').props('color=red') or for a button without background ui.button('Click me!').props('flat') Note that these solutions yield different button text colors, also depending on whether you run in dark or light mode. |
Beta Was this translation helpful? Give feedback.
-
@falkoschindler Thanks for your reply, find this topic with search. Although it is generally not recommended in web design, you can use !important to increase the priority of your custom styles. This will allow you to, for example, apply a currently popular gradient. I couldn't find other ways to set a gradient on a button, so this might be useful to someone :) ui.button('Click me').style(add='background: linear-gradient(to right, yellow, orange) !important; color: black !important;') |
Beta Was this translation helpful? Give feedback.
The default background color of a button is not generated with a class but with a prop. Therefore removing "bg-primary" does not work.
If you want to set the background color to a different value you can use
or
or for a button without background
Note that these solutions yield different button text colors, also depending on whether you run in dark or light mode.