textarea.py 1.1 KB

123456789101112131415161718192021222324252627
  1. from typing import Any, Callable, Dict, Optional
  2. from .input import Input
  3. class Textarea(Input):
  4. def __init__(self,
  5. label: Optional[str] = None, *,
  6. placeholder: Optional[str] = None,
  7. value: str = '',
  8. on_change: Optional[Callable[..., Any]] = None,
  9. validation: Dict[str, Callable[..., bool]] = {},
  10. ) -> None:
  11. """Textarea
  12. This element is based on Quasar's `QInput <https://quasar.dev/vue-components/input>`_ component.
  13. The ``type`` is set to ``textarea`` to create a multi-line text input.
  14. :param label: displayed name for the textarea
  15. :param placeholder: text to show if no value is entered
  16. :param value: the initial value of the field
  17. :param on_change: callback to execute when the value changes
  18. :param validation: dictionary of validation rules, e.g. ``{'Too short!': lambda value: len(value) < 3}``
  19. """
  20. super().__init__(label, placeholder=placeholder, value=value, on_change=on_change, validation=validation)
  21. self._props['type'] = 'textarea'