button.py 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. """A button component."""
  2. from typing import List
  3. from reflex.components.libs.chakra import ChakraComponent
  4. from reflex.vars import Var
  5. class Button(ChakraComponent):
  6. """The Button component is used to trigger an event or event, such as submitting a form, opening a dialog, canceling an event, or performing a delete operation."""
  7. tag = "Button"
  8. # The space between the button icon and label.
  9. icon_spacing: Var[int]
  10. # If true, the button will be styled in its active state.
  11. is_active: Var[bool]
  12. # If true, the button will be styled in its disabled state.
  13. is_disabled: Var[bool]
  14. # If true, the button will take up the full width of its container.
  15. is_full_width: Var[bool]
  16. # If true, the button will show a spinner.
  17. is_loading: Var[bool]
  18. # The label to show in the button when isLoading is true If no text is passed, it only shows the spinner.
  19. loading_text: Var[str]
  20. # "lg" | "md" | "sm" | "xs"
  21. size: Var[str]
  22. # "ghost" | "outline" | "solid" | "link" | "unstyled"
  23. variant: Var[str]
  24. # Built in color scheme for ease of use.
  25. # Options:
  26. # "whiteAlpha" | "blackAlpha" | "gray" | "red" | "orange" | "yellow" | "green" | "teal" | "blue" | "cyan"
  27. # | "purple" | "pink" | "linkedin" | "facebook" | "messenger" | "whatsapp" | "twitter" | "telegram"
  28. color_scheme: Var[str]
  29. # Position of the loading spinner.
  30. # Options:
  31. # "start" | "end"
  32. spinner_placement: Var[str]
  33. # The type of button.
  34. type_: Var[str]
  35. # Components that are not allowed as children.
  36. invalid_children: List[str] = ["Button", "MenuButton"]
  37. class ButtonGroup(ChakraComponent):
  38. """A group of buttons."""
  39. tag = "ButtonGroup"
  40. # If true, the borderRadius of button that are direct children will be altered to look flushed together.
  41. is_attached: Var[bool]
  42. # If true, all wrapped button will be disabled.
  43. is_disabled: Var[bool]
  44. # The spacing between the buttons.
  45. spacing: Var[int]
  46. # "lg" | "md" | "sm" | "xs"
  47. size: Var[str]
  48. # "ghost" | "outline" | "solid" | "link" | "unstyled"
  49. variant: Var[str]