checkbox_group.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. """Components for the CheckboxGroup component of Radix Themes."""
  2. from collections.abc import Sequence
  3. from types import SimpleNamespace
  4. from typing import Literal
  5. from reflex.components.core.breakpoints import Responsive
  6. from reflex.vars.base import Var
  7. from ..base import LiteralAccentColor, RadixThemesComponent
  8. class CheckboxGroupRoot(RadixThemesComponent):
  9. """Root element for a CheckboxGroup component."""
  10. tag = "CheckboxGroup.Root"
  11. # Use the size prop to control the checkbox size.
  12. size: Var[Responsive[Literal["1", "2", "3"]]]
  13. # Variant of button: "classic" | "surface" | "soft"
  14. variant: Var[Literal["classic", "surface", "soft"]]
  15. # Override theme color for button
  16. color_scheme: Var[LiteralAccentColor]
  17. # Uses a higher contrast color for the component.
  18. high_contrast: Var[bool]
  19. # determines which checkboxes, if any, are checked by default.
  20. default_value: Var[Sequence[str]]
  21. # used to assign a name to the entire group of checkboxes
  22. name: Var[str]
  23. class CheckboxGroupItem(RadixThemesComponent):
  24. """An item in the CheckboxGroup component."""
  25. tag = "CheckboxGroup.Item"
  26. # specifies the value associated with a particular checkbox option.
  27. value: Var[str]
  28. # Use the native disabled attribute to create a disabled checkbox.
  29. disabled: Var[bool]
  30. class CheckboxGroup(SimpleNamespace):
  31. """CheckboxGroup components namespace."""
  32. root = staticmethod(CheckboxGroupRoot.create)
  33. item = staticmethod(CheckboxGroupItem.create)
  34. checkbox_group = CheckboxGroup()