tooltip.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. """Tooltip components."""
  2. from typing import Set
  3. from pynecone.components.libs.chakra import ChakraComponent
  4. from pynecone.vars import Var
  5. class Tooltip(ChakraComponent):
  6. """A tooltip message to appear."""
  7. tag = "Tooltip"
  8. # The padding required to prevent the arrow from reaching the very edge of the popper.
  9. arrow_padding: Var[int]
  10. # The color of the arrow shadow.
  11. arrow_shadow_color: Var[str]
  12. # Size of the arrow.
  13. arrow_size: Var[int]
  14. # Delay (in ms) before hiding the tooltip
  15. delay: Var[int]
  16. # If true, the tooltip will hide on click
  17. close_on_click: Var[bool]
  18. # If true, the tooltip will hide on pressing Esc key
  19. close_on_esc: Var[bool]
  20. # If true, the tooltip will hide while the mouse is down
  21. close_on_mouse_down: Var[bool]
  22. # If true, the tooltip will be initially shown
  23. default_is_open: Var[bool]
  24. # Theme direction ltr or rtl. Popper's placement will be set accordingly
  25. direction: Var[str]
  26. # The distance or margin between the reference and popper. It is used internally to create an offset modifier. NB: If you define offset prop, it'll override the gutter.
  27. gutter: Var[int]
  28. # If true, the tooltip will show an arrow tip
  29. has_arrow: Var[bool]
  30. # If true, the tooltip with be disabled.
  31. is_disabled: Var[bool]
  32. # If true, the tooltip will be open.
  33. is_open: Var[bool]
  34. # The label of the tooltip
  35. label: Var[str]
  36. # Delay (in ms) before showing the tooltip
  37. open_delay: Var[int]
  38. # The placement of the popper relative to its reference.
  39. placement: Var[str]
  40. # If true, the tooltip will wrap its children in a `<span/>` with `tabIndex=0`
  41. should_wrap_children: Var[bool]
  42. def get_triggers(self) -> Set[str]:
  43. """Get the event triggers for the component.
  44. Returns:
  45. The event triggers.
  46. """
  47. return super().get_triggers() | {"on_close", "on_open"}