input_documentation.py 779 B

123456789101112131415161718192021
  1. from nicegui import ui
  2. from ..documentation_tools import text_demo
  3. def main_demo() -> None:
  4. ui.input(label='Text', placeholder='start typing',
  5. on_change=lambda e: result.set_text('you typed: ' + e.value),
  6. validation={'Input too long': lambda value: len(value) < 20})
  7. result = ui.label()
  8. def more() -> None:
  9. @text_demo('Auto complete input', '''
  10. The `autocomplete` feature provides suggestions as you type, making input easier and faster.
  11. The parameter `options` is a list of strings that contains the available options that will appear.
  12. ''')
  13. async def autocomplete_demo():
  14. options = ['AutoComplete', 'NiceGUI', 'Awesome']
  15. ui.input(label='Text', placeholder='start typing', autocomplete=options)