Ver Fonte

adding toggle doc

Rodja Trappe há 4 anos atrás
pai
commit
6a58917798
2 ficheiros alterados com 12 adições e 1 exclusões
  1. 4 0
      main.py
  2. 8 1
      nicegui/elements/toggle.py

+ 4 - 0
main.py

@@ -123,6 +123,10 @@ with example(ui.radio):
     radio = ui.radio(options=[1, 2, 3], value=1, design='inline')
     ui.radio(options={1: 'A', 2: 'B', 3: 'C'}, value=1, design='inline').bind_value(radio.value)
 
+with example(ui.toggle):
+    toggle = ui.toggle(options=[1, 2, 3], value=1)
+    ui.toggle(options={1: 'A', 2: 'B', 3: 'C'}, value=1).bind_value(toggle.value)
+
 with example(ui.select):
     with ui.row():
         select = ui.select(options=[1, 2, 3], value=1, design='inline')

+ 8 - 1
nicegui/elements/toggle.py

@@ -9,8 +9,15 @@ class Toggle(ChoiceElement):
                  value: any = None,
                  on_change: Callable = None,
                  design: str = '',
-                 classes:str='',
+                 classes: str = '',
                  ):
+        """Toggle Element
+
+        :param options: a list or dict specifying the options
+        :param value: the inital value
+        :param on_change: callback when selection changes
+        :param design: Quasar props to alter the appearance (see `their reference <https://quasar.dev/vue-components/toggle>`_)
+        """
 
         view = jp.QBtnToggle(input=self.handle_change)