range_documentation.py 866 B

1234567891011121314151617181920212223242526
  1. from nicegui import ui
  2. from . import doc
  3. @doc.demo(ui.range)
  4. def main_demo() -> None:
  5. min_max_range = ui.range(min=0, max=100, value={'min': 20, 'max': 80})
  6. ui.label().bind_text_from(min_max_range, 'value',
  7. backward=lambda v: f'min: {v["min"]}, max: {v["max"]}')
  8. @doc.demo('Customize labels', '''
  9. You can customize the colors of the range and its labels by setting them individually or for the range in total.
  10. ''')
  11. def customize_labels():
  12. ui.label('Color the entire range')
  13. ui.range(min=0, max=100, value={'min': 20, 'max': 80}) \
  14. .props('label snap color="secondary"')
  15. ui.label('Customize the color of the labels')
  16. ui.range(min=0, max=100, value={'min': 40, 'max': 80}) \
  17. .props('label-always snap label-color="secondary" right-label-text-color="black"')
  18. doc.reference(ui.range)