How to use scoped slots? #167
-
There is a feature in Vue named scoped slots. Judging by the sources of JustPy and NiceGUI, they seem to use this feature, albeit not frequently. nicegui/nicegui/elements/color_input.py Lines 28 to 34 in 0f67521 How do scoped slots work? My specific problem is that I wanted to do something like https://v1.quasar.dev/vue-components/tree#customize-content - header and body customization for tree nodes. Some additional text like "story" in that example, or notice how they put a Switch control under one of tree nodes. How can I do this with NiceGUI? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
Actually, I don't know much about scoped slots. The example you're citing from color_input.py is borrowed from https://justpy.io/quasar_tutorial/quasar_components/#qcolor. It does the job, but I can't say how to apply it to Since it's (currently) beyond NiceGUI's core features, I'll convert this issue to a Q&A discussion. If we find a solution with either JustPy or NiceGUI, we can think about how to integrate it into |
Beta Was this translation helpful? Give feedback.
-
Hey ! I got it to work :) Here is the tree example using both a scoped slot (to inject the icon properly) and the named slot (actually the body scoped slot, used without the inject props, therefore as a named slots). It demonstrates that can be done without breaking on any of currently working functionnality, but adding the scoped slots: The example personnalizes the QTree as shown in : https://quasar.dev/vue-components/tree#customize-content using the data and build shown in the reference QTree element at https://nicegui.io/reference#tree The technique works with any element from Quasar. That really gives us a whole new level to customize the elements just as the documentation of Quasar shows, including QTable too (as per PR #500). It is (a bit past) 2PM here so I have to get back to work, but I will push a PR with scoped slots very soon (hopefully tonight). |
Beta Was this translation helpful? Give feedback.
-
We just released NiceGUI 1.2.0 with officially supports scoped slots. 🎉 https://github.com/zauberzeug/nicegui/blob/main/examples/slots/main.py |
Beta Was this translation helpful? Give feedback.
We just released NiceGUI 1.2.0 with officially supports scoped slots. 🎉
https://github.com/zauberzeug/nicegui/blob/main/examples/slots/main.py