button.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. # The type of button.
  30. type_: Var[str]
  31. # Components that are not allowed as children.
  32. invalid_children: List[str] = ["Button", "MenuButton"]
  33. class ButtonGroup(ChakraComponent):
  34. """A group of buttons."""
  35. tag = "ButtonGroup"
  36. # If true, the borderRadius of button that are direct children will be altered to look flushed together.
  37. is_attached: Var[bool]
  38. # If true, all wrapped button will be disabled.
  39. is_disabled: Var[bool]
  40. # The spacing between the buttons.
  41. spacing: Var[int]