ui.list "current selection" implementation #5554
-
First Check
Example Codefrom nicegui import ui
current_index_slider = ui.slider(0, min=0, max=10)
data = ["hello", "test", "truc", "trac"]
with ui.list().props('dense separator'):
for i in data:
ui.item(i).classes("bg-green if current_index else bg-white")
ui.run()DescriptionHi, I would like to know how to display current item selection . For instance, when you click on an item , or if you select the current index from a slider, the current item must display green background. NiceGUI Version3.3.1 Python Version3.13.2 BrowserFirefox Operating SystemLinux Additional ContextNo response |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
Hi @dridk, Here are three possible approaches to choose from:
|
Beta Was this translation helpful? Give feedback.
Hi @dridk,
Here are three possible approaches to choose from:
Wrap your
ui.listin a refreshable function and refresh it whenever the slider value changes:Register a value change event handler for every individual list item: