Skip to content

Commit

Permalink
checkbox example
Browse files Browse the repository at this point in the history
  • Loading branch information
rodja committed May 19, 2021
1 parent ca14525 commit 355e09b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ def button_increment():
ui.button('Button', on_click=button_increment)
button_result = ui.label('pressed: 0')

with example(ui.checkbox):

ui.checkbox('check me', on_change=lambda e: checkbox_state.set_text(e.value))
with ui.row():
ui.label('the checkbox is:')
checkbox_state = ui.label('False')

with example(ui.input):

ui.input(
Expand Down
6 changes: 6 additions & 0 deletions nicegui/elements/checkbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ def __init__(self,
value: bool = False,
design: str = '',
on_change: Callable = None):
"""Checkbox Element
:param text: the label to display beside the checkbox
:param value: set to True if initally it should be checked; default is False
:param design: Quasar props to alter the appearance (see `their reference <https://quasar.dev/vue-components/checkbox>`_)
:param on_change: callback to execute when value changes
"""
view = jp.QCheckbox(text=text, input=self.handle_change)

super().__init__(view, design, value, on_change)

0 comments on commit 355e09b

Please sign in to comment.