accordion.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. """Container to stack elements with spacing."""
  2. from typing import List, Optional, Union
  3. from pynecone.components.libs.chakra import ChakraComponent
  4. from pynecone.var import Var
  5. class Accordion(ChakraComponent):
  6. """The wrapper that uses cloneElement to pass props to AccordionItem children."""
  7. tag = "Accordion"
  8. # If true, multiple accordion items can be expanded at once.
  9. allow_multiple: Var[bool]
  10. # If true, any expanded accordion item can be collapsed again.
  11. allow_toggle: Var[bool]
  12. # The initial index(es) of the expanded accordion item(s).
  13. default_index: Var[Optional[List[int]]]
  14. # The index(es) of the expanded accordion item
  15. index: Var[Union[int, List[int]]]
  16. # If true, height animation and transitions will be disabled.
  17. reduce_motion: Var[bool]
  18. class AccordionItem(ChakraComponent):
  19. """A single accordion item."""
  20. tag = "AccordionItem"
  21. # A unique id for the accordion item.
  22. id_: Var[str]
  23. # If true, the accordion item will be disabled.
  24. is_disabled: Var[bool]
  25. # If true, the accordion item will be focusable.
  26. is_focusable: Var[bool]
  27. class AccordionButton(ChakraComponent):
  28. """The button that toggles the expand/collapse state of the accordion item. This button must be wrapped in an element with role heading."""
  29. tag = "AccordionButton"
  30. class AccordionPanel(ChakraComponent):
  31. """The container for the details to be revealed."""
  32. tag = "AccordionPanel"
  33. class AccordionIcon(ChakraComponent):
  34. """A chevron-down icon that rotates based on the expanded/collapsed state."""
  35. tag = "AccordionIcon"