button.py 2.4 KB

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