1
0

date_documentation.py 924 B

12345678910111213141516171819202122232425
  1. from nicegui import ui
  2. from ..documentation_tools import text_demo
  3. def main_demo() -> None:
  4. ui.date(value='2023-01-01', on_change=lambda e: result.set_text(e.value))
  5. result = ui.label()
  6. def more() -> None:
  7. @text_demo('Input element with date picker', '''
  8. This demo shows how to implement a date picker with an input element.
  9. We place an icon in the input element's append slot.
  10. When the icon is clicked, we open a menu with a date picker.
  11. The date is bound to the input element's value.
  12. So both the input element and the date picker will stay in sync whenever the date is changed.
  13. ''')
  14. def date():
  15. with ui.input('Date') as date:
  16. with date.add_slot('append'):
  17. ui.icon('edit_calendar').on('click', lambda: menu.open()).classes('cursor-pointer')
  18. with ui.menu() as menu:
  19. ui.date().bind_value(date)