Filling knob with gradient #5525
Unanswered
Viacheslav96
asked this question in
Q&A
Replies: 1 comment 2 replies
-
|
Hi @Viacheslav96, The correct selector seems to be ".q-circular-progress__circle": ui.add_body_html('''
<svg style="position: absolute">
<defs>
<linearGradient id="knobGradient" x1="100%" y1="100%" x2="0%" y2="0%">
<stop offset="0%" stop-color="#ea2015" />
<stop offset="100%" stop-color="#41be69" />
</linearGradient>
</defs>
</svg>
''')
ui.add_css('''
.q-circular-progress__circle {
stroke: url(#knobGradient) !important;
}
''')
ui.knob(value=0.5, show_value=True, track_color='grey-4', size='16rem').classes('gradient-knob')
But you probably want a conic gradient instead of a linear one. Unfortunately there seems to be no such gradient in SVG and we need to find some CSS hack to work around this limitation. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

Uh oh!
There was an error while loading. Please reload this page.
-
First Check
Example Code
Description
I want to create a knob control that will be filled with gradient colouring. But doing it in a way that I did, I can no longer set the colour of the track itself. Is there a better way to do it? Also, if I go to 100 on the knob, the gradient starts to go back to red. If anyone knows how to fix it, I'll appreciate it
NiceGUI Version
3.0.3
Python Version
Python 3.12.3
Browser
Chrome
Operating System
Linux
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions